Taking input from the user in java

 package mypro;

 

import java.util.Scanner;






//public class MyOwn{

//

// static void lakshman1() {

//     System.out.println("I just got executed!");

//   }

//}


public class TakingInputFromTheUser {

static void lakshman() {

      System.out.println("I just got executed!");

    }


      public static void main(String[] args) {

     Scanner obj = new Scanner(System.in);

     System.out.println("Enter the value of a : ");

     String a = obj.nextLine();

     System.out.println("Enter the value of b : ");

     int b = obj.nextInt();

     System.out.println("The sum of a and b is : "+(a+b));

     

    lakshman();

       

      }

  

}


Comments

Popular posts from this blog

250+ C Programs for Practice

FUNCTION OVERRIDING IN CPP