Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming

Reply
 
LinkBack Thread Tools
Old 04-07-07   #1 (permalink)
nVidia Enthusiast
 
ModeX's Avatar
 
intel nvidia

Join Date: Oct 2006
Posts: 348

Rep: 6 ModeX Unknown
Unique Rep: 6
Trader Rating: 0
Question Java, what is char mainly used for?

Other than for switches, I really haven't found any uses for char. My book doesn't explain much about char, and google didn't turn up any results(or at least results I could understand ). Also why is char needed? I just want to know if I'm missing something big about not knowing how to use char that's all, all help will be very appreciated!
__________________
"We are all prophets, that is why we make so many mistakes"

"One who wears a mask wants to become someone else
one who wears a mask somewhere other than the face wants to become many"

"The truth is a lie"

"There are only a few free people in the world, the insane"

System: The System
CPU
e6600
Motherboard
asus striker extreme
Memory
2gb supertalent pc2 6400
Graphics Card
Evga 8800 gtx
Hard Drive
maxtor
Sound Card
stock
Power Supply
coolermaster 550watt
Case
Thermaltake Kandalf (Modded)
CPU cooling
big typhoon
GPU cooling
8800 tx evga
OS
xp professional
Monitor
1920*1200 ress sony
ModeX is offline   Reply With Quote
Old 04-07-07   #2 (permalink)
Apple Doesn't Love You
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 4,975
Blog Entries: 1

Rep: 564 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 338
FAQs Submitted: 6
Trader Rating: 5
Default

Flags, various uses pertaining to strings, plenty of stuff

Admittedly char's are not as powerful in java as in other languages. C, for example, does not have strings, but rather arrays of char's (java's string class is really pretty much just that, but there is a separate class for it).

That question is very hard to answer tho - kinda like "what do I use a nail for?" Depending on what you need to do you may have a hundred uses for chars or none
__________________
BIG BROTHER
I put on my robe and wizard hat...

IS WATCHING

System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 04-07-07   #3 (permalink)
nVidia Enthusiast
 
ModeX's Avatar
 
intel nvidia

Join Date: Oct 2006
Posts: 348

Rep: 6 ModeX Unknown
Unique Rep: 6
Trader Rating: 0
Default

The reason why I asked is because even though I'm a newb, if I were to make a program with Java I wouldn't think of using chars. I was wondering if that would be a problem thats all
__________________
"We are all prophets, that is why we make so many mistakes"

"One who wears a mask wants to become someone else
one who wears a mask somewhere other than the face wants to become many"

"The truth is a lie"

"There are only a few free people in the world, the insane"

System: The System
CPU
e6600
Motherboard
asus striker extreme
Memory
2gb supertalent pc2 6400
Graphics Card
Evga 8800 gtx
Hard Drive
maxtor
Sound Card
stock
Power Supply
coolermaster 550watt
Case
Thermaltake Kandalf (Modded)
CPU cooling
big typhoon
GPU cooling
8800 tx evga
OS
xp professional
Monitor
1920*1200 ress sony
ModeX is offline   Reply With Quote
Old 04-07-07   #4 (permalink)
Apple Doesn't Love You
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 4,975
Blog Entries: 1

Rep: 564 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 338
FAQs Submitted: 6
Trader Rating: 5
Default

No - if you don't need char's that isn't a problem. Remember too that while you're learning the programs you create do more or less nothing. The scope is so small that it isn't surprising that you don't need some stuff
__________________
BIG BROTHER
I put on my robe and wizard hat...

IS WATCHING

System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 04-07-07   #5 (permalink)
Jack of all trades
 
H3||scr3am's Avatar
 
intel nvidia

Join Date: Mar 2007
Location: Cambridge, Ontario
Posts: 3,562

Rep: 271 H3||scr3am is a proven memberH3||scr3am is a proven memberH3||scr3am is a proven member
Unique Rep: 208
Trader Rating: 2
Default

I personally use chars as a catch, or a break from a loop. so a conditional flag. You can do it without using chars though...
__________________

I am 91% addicted to Counterstrike. What about you?
OCN CS:S GG: overclock.nuclearfallout.net:27015
OCN TF2: 8.9.16.94:27015 (temporary)
[CSS GUN GAME ADMIN] Ban Hamma of Pwnage +5 skillz
[TF2 ADMIN] Ban Hammer of scouting + 20 scout powaz

System: B3 Holds me back :(
CPU
Intel Q6600 (L664G)
Motherboard
Asus P5K Deluxe
Memory
G.Skill 2GB HZs & 2GB Ballistix
Graphics Card
eVGA GeForce 8800 GTX
Hard Drive
WD SATA HD 250GB
Sound Card
Auzentech X-Fi Prelude
Power Supply
Silverstone Decathlon 750W
Case
TT Armor w/ 25cm side fan
CPU cooling
D-Tek FuZion WB
GPU cooling
DD 8800 WB
OS
XP pro SP3 :D
Monitor
2x 21" Sony G400 CRTs
H3||scr3am is offline Overclocked Account H3||scr3am's Gallery   Reply With Quote
Old 04-07-07   #6 (permalink)
Photography nut
 
dangerousHobo's Avatar
 
amd nvidia

Join Date: Dec 2005
Location: ~/
Posts: 3,469

FAQs Submitted: 7
Folding Team Rank: 391
Trader Rating: 0
Default

Like rabidgnome229 basically already said. In languages like C/C++ (and many others), there are no strings, in the java sense of a string. So to have a string in those languages you create an array of characters. Java does the same thing but it happens behind the scenes and you don't have to worry about it. There is a String class is java that takes care of that. I don't use chars that often either, I tend to use boolean instance variables as flag, unless their are many option and then usually I try using an array to manage the objects, so then I'm dealing with integers.
It just all depends on the task at hand and how you think about solving the problem. There is nothing wrong with not thinking to use chars in a situation though.
__________________
"UNIX was never designed to keep people from doing stupid things, because that policy would also keep them from doing clever things." - Doug Gwyn

Try out the latest Programming Challenge
Quote:
Originally Posted by Melcar
Only one reasonable way to solve this... a dance off.

CPU-Z Validation
@ 2.97-prime95 stable 16 hours @ 1.48v Proof | CPU-Z Validation @ 3.15


Getting Mouse Side Buttons to work in Linux, Compile a custom Kernel, More

System: Anomaly
CPU
Athlon 3700 SD(KACAE)0546 @3.02ghz
Motherboard
DFI UT nF4 Ultra-D
Memory
G.Skill 2x512 UTT(BH-5)
Graphics Card
evga 6800gs
Hard Drive
Maxtor 300GB + WD 250GB
Sound Card
onboard
Power Supply
Ultra 500w V-series
Case
one from Ultra
CPU cooling
Big Typhoon
GPU cooling
80mm fan mounted on
OS
Arch64
Monitor
Acer AL2216W 22" WS LCD
dangerousHobo is offline I fold for Overclock.net Overclocked Account dangerousHobo's Gallery   Reply With Quote
Old 04-07-07   #7 (permalink)
nVidia Enthusiast
 
ModeX's Avatar
 
intel nvidia

Join Date: Oct 2006
Posts: 348

Rep: 6 ModeX Unknown
Unique Rep: 6
Trader Rating: 0
Default

Quote:
Originally Posted by H3||scr3am View Post
I personally use chars as a catch, or a break from a loop. so a conditional flag. You can do it without using chars though...
could you give me a simple example of that pls
__________________
"We are all prophets, that is why we make so many mistakes"

"One who wears a mask wants to become someone else
one who wears a mask somewhere other than the face wants to become many"

"The truth is a lie"

"There are only a few free people in the world, the insane"

System: The System
CPU
e6600
Motherboard
asus striker extreme
Memory
2gb supertalent pc2 6400
Graphics Card
Evga 8800 gtx
Hard Drive
maxtor
Sound Card
stock
Power Supply
coolermaster 550watt
Case
Thermaltake Kandalf (Modded)
CPU cooling
big typhoon
GPU cooling
8800 tx evga
OS
xp professional
Monitor
1920*1200 ress sony
ModeX is offline   Reply With Quote
Old 04-07-07   #8 (permalink)
Photography nut
 
dangerousHobo's Avatar
 
amd nvidia

Join Date: Dec 2005
Location: ~/
Posts: 3,469

FAQs Submitted: 7
Folding Team Rank: 391
Trader Rating: 0
Default

Quote:
Originally Posted by ModeX View Post
could you give me a simple example of that pls

Code:
try{
      if(num<0)
            throw new NegitiveNumberException();
       /**Code*/
}
catch(NegitiveNumberExceptio e){
         System.out.println(e.getMessage());
}



String word=""
String lineInDatabase="3; cups; suger";
for(int i=0;i<lineInDatabase.length;++i){
     if(lineInDatabase.chatAt(i)!=';')
          word+=lineInDatabase.charAt(i);
}
Those are simple examples, but hopefully you get the idea.
__________________
"UNIX was never designed to keep people from doing stupid things, because that policy would also keep them from doing clever things." - Doug Gwyn

Try out the latest Programming Challenge
Quote:
Originally Posted by Melcar
Only one reasonable way to solve this... a dance off.

CPU-Z Validation
@ 2.97-prime95 stable 16 hours @ 1.48v Proof | CPU-Z Validation @ 3.15


Getting Mouse Side Buttons to work in Linux, Compile a custom Kernel, More

System: Anomaly
CPU
Athlon 3700 SD(KACAE)0546 @3.02ghz
Motherboard
DFI UT nF4 Ultra-D
Memory
G.Skill 2x512 UTT(BH-5)
Graphics Card
evga 6800gs
Hard Drive
Maxtor 300GB + WD 250GB
Sound Card
onboard
Power Supply
Ultra 500w V-series
Case
one from Ultra
CPU cooling
Big Typhoon
GPU cooling
80mm fan mounted on
OS
Arch64
Monitor
Acer AL2216W 22" WS LCD
dangerousHobo is offline I fold for Overclock.net Overclocked Account dangerousHobo's Gallery   Reply With Quote
Old 04-08-07   #9 (permalink)
nVidia Enthusiast
 
ModeX's Avatar
 
intel nvidia

Join Date: Oct 2006
Posts: 348

Rep: 6 ModeX Unknown
Unique Rep: 6
Trader Rating: 0
Default

Quote:
Originally Posted by dangerousHobo View Post
Code:
try{
      if(num<0)
            throw new NegitiveNumberException();
       /**Code*/
}
catch(NegitiveNumberExceptio e){
         System.out.println(e.getMessage());
}



String word=""
String lineInDatabase="3; cups; suger";
for(int i=0;i<lineInDatabase.length;++i){
     if(lineInDatabase.chatAt(i)!=';')
          word+=lineInDatabase.charAt(i);
}
Those are simple examples, but hopefully you get the idea.
Why cups and suger Any way Thank You
__________________
"We are all prophets, that is why we make so many mistakes"

"One who wears a mask wants to become someone else
one who wears a mask somewhere other than the face wants to become many"

"The truth is a lie"

"There are only a few free people in the world, the insane"

System: The System
CPU
e6600
Motherboard
asus striker extreme
Memory
2gb supertalent pc2 6400
Graphics Card
Evga 8800 gtx
Hard Drive
maxtor
Sound Card
stock
Power Supply
coolermaster 550watt
Case
Thermaltake Kandalf (Modded)
CPU cooling
big typhoon
GPU cooling
8800 tx evga
OS
xp professional
Monitor
1920*1200 ress sony
ModeX is offline   Reply With Quote
Old 04-08-07   #10 (permalink)
Photography nut
 
dangerousHobo's Avatar
 
amd nvidia

Join Date: Dec 2005
Location: ~/
Posts: 3,469

FAQs Submitted: 7
Folding Team Rank: 391
Trader Rating: 0
Default


I had to write a program for a class that managed a database of recipes, and was able to add files thats contained a recipe's list of ingredients in that order: quantity; measure; name.
So it was just fresh in my mind.
__________________
"UNIX was never designed to keep people from doing stupid things, because that policy would also keep them from doing clever things." - Doug Gwyn

Try out the latest Programming Challenge
Quote:
Originally Posted by Melcar
Only one reasonable way to solve this... a dance off.

CPU-Z Validation
@ 2.97-prime95 stable 16 hours @ 1.48v Proof | CPU-Z Validation @ 3.15


Getting Mouse Side Buttons to work in Linux, Compile a custom Kernel, More

System: Anomaly
CPU
Athlon 3700 SD(KACAE)0546 @3.02ghz
Motherboard
DFI UT nF4 Ultra-D
Memory
G.Skill 2x512 UTT(BH-5)
Graphics Card
evga 6800gs
Hard Drive
Maxtor 300GB + WD 250GB
Sound Card
onboard
Power Supply
Ultra 500w V-series
Case
one from Ultra
CPU cooling
Big Typhoon
GPU cooling
80mm fan mounted on
OS
Arch64
Monitor
Acer AL2216W 22" WS LCD
dangerousHobo is offline I fold for Overclock.net Overclocked Account dangerousHobo's Gallery   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 10:23 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.35187 seconds with 8 queries