Presentation is loading. Please wait.

Presentation is loading. Please wait.

import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.

Similar presentations


Presentation on theme: "import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter."— Presentation transcript:

1

2 import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter 1st Value: "); num1=input.nextInt(); System.out.println(“Number Entered = " + num1); }

3 import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter 1st Value: "); num1=input.nextInt(); System.out.println(“Number Entered = " + num1); } This the Package which contain the classes for getting input from the user

4 Import is used to include external packages in your code import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter 1st Value: "); num1=input.nextInt(); System.out.println(“Number Entered = " + num1); }

5 Here we are creating an object of the Scanner class that we have imported in out java code… where input is name of the object… by the help of this input object we are going to take input from the users. import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter 1st Value: "); num1=input.nextInt(); System.out.println(“Number Entered = " + num1); }

6 new reserved word is used to create an object of the class… import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter 1st Value: "); num1=input.nextInt(); System.out.println(“Number Entered = " + num1); }

7 System.in is an input stream import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter 1st Value: "); num1=input.nextInt(); System.out.println(“Number Entered = " + num1); }

8 input.nextInt() would take the input from the user and would assign it to a variable num1. import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter 1st Value: "); num1=input.nextInt(); System.out.println(“Number Entered = " + num1); } }

9


Download ppt "import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter."

Similar presentations


Ads by Google