java expert?? what the..
•
25 Nov 2008, 19:10
•
Journals
i have to do a java program which is calculating the area of a box for me.
but how should i do this?
i really don't understand the meaning of all those commands and stuff because they kinda vary from every time i visit class
so i start with:
import java.io.*;
class Test{
public static void main (string args[]) throws IOException //why that?
and then something like
Scanner sc = newScanner (System.in);
string str = sc.nextLine();
or
BufferedReader input = new BufferedReader
new InputStreamReader (System.in)
and then?? i have no idea coz i cant imagine what the hell those commands actually do :(
but how should i do this?
i really don't understand the meaning of all those commands and stuff because they kinda vary from every time i visit class
so i start with:
import java.io.*;
class Test{
public static void main (string args[]) throws IOException //why that?
and then something like
Scanner sc = newScanner (System.in);
string str = sc.nextLine();
or
BufferedReader input = new BufferedReader
new InputStreamReader (System.in)
and then?? i have no idea coz i cant imagine what the hell those commands actually do :(
http://java.sun.com/reference/docs/
You should normally import the scanner also (import java.util.Scanner;)
Scanner input = new Scanner (System.in);
and dont forget the "public" -> public class Test{
I have only just learned the basics of java though...
you don't need to worry about that, I'm not sure if you don't understand the two other bits of code,
first is creating a new object Scanner and sending the input into a function called nextLine within that class,
the other is just reading the input.
I'd recommend reading your class notes and lecture notes as it'll surely discuss all this :X
but thx helped me a bit