package All_in_one; import java.util.Scanner; //for taking input public class java_basic { //10.function static void myData(){ System.out.printf("RajoMay Data Loading..."); } static int myData(int a){ return a*100; } public static void main(String args[]) { 1.print on console System.out.print("Rajomay"); System.out.println("Rajomay"); //print with next line //_____________________________________________________________________________________________________________ //2.Taking input int a; Scanner scan = new Scanner(System.in); a = scan.nextInt(); System.out.println("your entered no. : "+a); //_____________________________________________________________________________________________________________ //3.Data Types (Note-: java does not support long long) byte a4; short a1; int a2; long a3; float b1; double b2; char a = 'a'; String b = "Rajoshree"; boolean a0 = true; //%b //_____________________________________________________________________________________________________________ //4.Multiline input a4 = scan.nextByte(); a1 = scan.nextShort(); a2 = scan.nextInt(); a3 = scan.nextLong(); b1 = scan.nextFloat(); b2 = scan.nextDouble(); a = scan.next().charAt(0); b = scan.nextLine(); System.out.printf("%d \n",a2); System.out.println(a3); System.out.println(b1); System.out.println(b2); System.out.println(a); System.out.println(b); System.out.printf("%b",a0); //_____________________________________________________________________________________________________________ //6.if/else if(true){ System.out.print("yes"); } else if(false){ System.out.print("no"); } else{ System.out.print("NA"); } ////_____________________________________________________________________________________________________________ //7.switch case (Note-: java support string case " ") switch("rajomay"){ case 1: System.out.printf("num"); break; case 'a': System.out.printf("char"); break; case "rajomay": System.out.printf("String"); break; default: System.out.printf("NA"); } //_____________________________________________________________________________________________________________ //8.for loops for(int i=1;i<=10;i++){ System.out.printf("%d \n",i); } //_____________________________________________________________________________________________________________ //9.while and do-while loop int i=44; while(i<10){ System.out.printf("%d \n",i); i++; } //--------------------------------------- do{ System.out.printf("%d \n",i); i++; }while(i<10); //_____________________________________________________________________________________________________________ //10.function myData(); System.out.printf("%d",myData(2)); //_____________________________________________________________________________________________________________ //11.Typecasting int i = 17; double d; char c; String ac; d = (double) i; c = (char) i; ac = String.valueOf(i); System.out.print( d ); System.out.print( c ); System.out.print( ac ); //_____________________________________________________________________________________________________________ } }