aspose file tools*
The moose likes Beginning Java and the fly likes String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String" Watch "String" New topic
Author

String

akhilesh bar
Greenhorn

Joined: Sep 10, 2010
Posts: 4
hi to everybody...
please tell me that why does Java takes input in the form of String??


@ {< {< !
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3168
    
  47

akhilesh bar wrote:why does Java takes input in the form of String??

What input? If the input is a text, String would be the best way to get it because String can hold a text.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
akhilesh bar
Greenhorn

Joined: Sep 10, 2010
Posts: 4
hi devaka..

according to my knowledge... java takes inputs as a string and then converts it into the desired type...for example static void main(String [] args) !!!
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

You're referring to command-line arguments. That's because java uses the String to hold text.
"Input" is very imprecise. Could you specify what do mean exactly.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11419
    
  16

because anything and everything you type from a keyboard CAN be represented as a String...but the same isn't really true for other variable types.

That's what I've always thought.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Ninad Kuchekar
Ranch Hand

Joined: Jan 05, 2010
Posts: 64
Hi Akhilesh,

Please be specific with your subject...thanks in advance.

If you are passing arguments from the console then they have to be accepted as text(in this case String format).
Even if you type in a number you have to parse the String to the desired format.

Don't walk as if you rule the world, walk as if you don't care who rules it...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: String