File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String" Watch "String" New topic


akhilesh bar

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

Joined: Jul 29, 2008
Posts: 3929

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

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

Joined: Oct 02, 2003
Posts: 11955

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...
I agree. Here's the link:
subject: String
It's not a secret anymore!