To get User Input in JAVA
System.out.print("Enter your name and press Enter: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String name = null;
try {
name = br.readLine();
} catch (IOException e) {
System.out.println("Error!");
System.exit(1);
}
System.out.println("Your name is " + name);
Convert the String of character "8" to actual numeric value 8
String num="8";
int z=Integer.parseInt(num);
To read a File
readTheFile("fileName.txt"); // use it with FileNotFoundException()
No comments:
Post a Comment