LEC 6 | JAVA
LEC:6
Taking Input From user in JAVA
Source Code:
package lec_5;
import java.util.*;
//import java.util.Scanner;
public class Lec_5 {
public static void main(String[] args) {
//addition of two numbers.
// System.out.println("Enter first Number : ");
// Scanner O1=new Scanner(System.in);
// int x=O1.nextInt();
// System.out.println("Enter Second Number : ");
// int y=O1.nextInt();
// int add=x+y;
// System.out.println("Addition of "+ x+ " and "+y+" is : "+add);
Scanner O1=new Scanner(System.in);
System.out.println("Enter your name");
String name=O1.nextLine();
System.out.println("Name is by using nextline()"+name);
String name1=O1.next();
System.out.println("Name is by using nextline()"+name1);
}
}
Comments
Post a Comment