In school we are using Ready To Program to learn Java and so we use a hsa.console to run the programs.
In ready we do the following to get the input from users:
String name = c.readLine();
String name = c.readString();
int age = c.readInt();
...and so on.
However I currently downloaded eclipse (On my mac if that helps) to do some more advanced Java programming outside of school. However I found out that it is much different from Ready.
For one we were able to so c.println(); in Ready where as in Eclipse we would have to do System.out.println();
So I was just wondering if anyone can help me to get input from Strings, Int, Doubles and etc. Thanks! :)
You can still use the hsa package in Eclipse. You just have to inlcude it in your project. How to do that is an Eclipse question and not Java. Either read about it in the help or ask in an Eclipse forum.
Or you can use the classes in the Java API. Google for an IO tutorial. One way to do it was to wrap a Bufferedreader around an InputStream. But as of Java 1.5 they introduced the Scanner class which can make getting input a bit easier. You can even use JOptionPane.
Hey Junky thanks for the reply!
The reason I do not want to use a hsa console is for the fact that it is not a standard (as my teacher told me).
However I Googled the scanner method and it worked! :D
Scanner input = new Scanner(System.in);
String name = input.next();
Thanks a lot! :D
Just remember to read about all the methods and what they do. If input was "Fred Flintstone" your code would only return "Fred".
Oh this was one of the problems I encountered in hsa: c.readString() and c.readLine().
I will look more into this, again thanks :)