Input Methods
Numeric Input
nextInt()- reads integernextFloat()- reads floatnextDouble()- reads doublenextByte()- reads bytenextShort()- reads shortnextLong()- reads long
Text Input
next()- reads single wordnextLine()- reads full linenextBoolean()- reads booleannext().charAt(int index)- reads character at index
Validation Methods
hasNextInt()and similar methods- Returns boolean (
true/false) - Useful for input validation before reading
System References
System.in- built-in object reference to keyboardSystem.out- built-in object reference to monitor/display
Command Line Arguments
-
Accessible through
args[]in the program -
Reference: See Command Line example (
CommandLine.java, below)CommandLine.java// using command line arguments in a java program public class CommandLine { public static void main(String[] args) { System.out.println("Command Line Arguments"); // if (args.length > 0) { // System.out.println(args[0]); // } else { // System.out.println("No arguments provided for args[0]"); // } // if (args.length > 1) { // System.out.println(args[1]); // } else { // System.out.println("No arguments provided for args[1]"); // } System.out.println(args[0]); System.out.println(args[1]); } }Runs in your browser with Java 21. Ctrl/โ + Enter to run.Built with CheerpJ