Console I/O in Java
- Output
-
System.out.println("Hello")
-
System.out.print("Hello")
- All data types are automatically converted to Strings
- Strings and other objects can be concatenated:
int x = 5;
System.out.println("The value of x is " + x);
- Tabs:
System.out.println("My name is:\t" + name);
- Input
- Much more complicated:
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter your name: ");
String name = in.readLine();
- And after all that, it won't even compile...
(next)