// Load required classes
import java.util.Scanner;
import java.io.File;

public class Conditionals{ public static void main(String[] args) throws Exception{ // Scanner variable Scanner reader;

// If an argument is present, we are reading from a file
// specified in args[0]
if(args.length > 0){
  reader = new Scanner(new File(args[0]));
// If no argument, read from System.in
}else{
  reader = new Scanner(System.in);
}

int x = reader.nextInt();
System.out.println(x);

} }

// Load required classes
import java.util.Scanner;
import java.io.File;

public class Conditionals{ public static void main(String[] args) throws Exception{ // Scanner variable Scanner reader;

// If an argument is present, we are reading from a file
// specified in args[0]
if(args.length > 0){
  reader = new Scanner(new File(args[0]));
// If no argument, read from System.in
}else{
  reader = new Scanner(System.in);
}

int x = reader.nextInt();
System.out.println(x);

} }

Forgot Imports?

error: cannot find symbol
    Scanner reader;
    ^
  symbol:   class Scanner
  location: class Conditionals
// Load required classes
import java.util.Scanner;
import java.io.File;

public class Conditionals{ public static void main(String[] args) throws Exception{ // Scanner variable Scanner reader;

// If an argument is present, we are reading from a file
// specified in args[0]
if(args.length > 0){
  reader = new Scanner(new File(args[0]));
// If no argument, read from System.in
}else{
  reader = new Scanner(System.in);
}

int x = reader.nextInt();
System.out.println(x);

} }

Forgot Throws Exception?

error: unreported exception FileNotFoundException;
       must be caught or declared to be thrown
       reader = new Scanner(new File(args[0]));
               ^
// Load required classes
import java.util.Scanner;
import java.io.File;

public class Conditionals{ public static void main(String[] args) throws Exception{ // Scanner variable Scanner reader;

// If an argument is present, we are reading from a file
// specified in args[0]
if(args.length > 0){
  reader = new Scanner(new File(args[0]));
// If no argument, read from System.in
}else{
  reader = new Scanner(System.in);
}

int x = reader.nextInt();
System.out.println(x);

} }

// Load required classes
import java.util.Scanner;
import java.io.File;

public class Conditionals{ public static void main(String[] args) throws Exception{ // Scanner variable Scanner reader;

// If an argument is present, we are reading from a file
// specified in args[0]
<mark>if(args.length > 0){
  reader = new Scanner(new File(args[0]));</mark>
// If no argument, read from System.in
}else{
  reader = new Scanner(System.in);
}

int x = reader.nextInt();
System.out.println(x);

} }

// Load required classes
import java.util.Scanner;
import java.io.File;

public class Conditionals{ public static void main(String[] args) throws Exception{ // Scanner variable Scanner reader;

// If an argument is present, we are reading from a file
// specified in args[0]
if(args.length > 0){
  reader = new Scanner(new File(args[0]));
// If no argument, read from System.in
<mark>}else{
  reader = new Scanner(System.in);
}</mark>

int x = reader.nextInt();
System.out.println(x);

} }

// Load required classes
import java.util.Scanner;
import java.io.File;

public class Conditionals{ public static void main(String[] args) throws Exception{ // Scanner variable Scanner reader;

// If an argument is present, we are reading from a file
// specified in args[0]
if(args.length > 0){
  reader = new Scanner(new File(args[0]));
// If no argument, read from System.in
}else{
  reader = new Scanner(System.in);
}

<mark>int x = reader.nextInt();</mark>
System.out.println(x);

} }

Reading Primitive Data Types

int i = reader.nextInt();
byte b = reader.nextByte();
short s = reader.nextShort();
long l = reader.nextLong();

boolean bool = reader.nextBoolean();

float f = reader.nextFloat(); double d = reader.nextDouble();

// Load required classes
import java.util.Scanner;
import java.io.File;

public class Conditionals{ public static void main(String[] args) throws Exception{ // Scanner variable Scanner reader;

// If an argument is present, we are reading from a file
// specified in args[0]
<mark>if(args.length > 0){
  reader = new Scanner(new File(args[0]));</mark>
// If no argument, read from System.in
<mark>}else{
  reader = new Scanner(System.in);
}</mark>

<mark>int x = reader.nextInt();</mark>
System.out.println(x);

} }

"/js/highlight.pack.js"