Literal


Code-1.

class LiteralEx{

static public void main(String s[]){

//int a=1__55_46_230;//allowed

//int a=_1_55_46_230;//NOT allowed 

//int a=1_55_46_230_;//NOT allowed

int a=1_55_46_230;

System.out.printf("%d\n",a);

}

}

Output:-

15546230

Code-2.

class LiteralEx2{

static public void main(String s[]){

//int a=1__55_46_230;//allowed

//int a=_1_55_46_230;//NOT allowed 

//int a=1_55_46_230_;//NOT allowed

int a=1_55_46_230;

System.out.printf("%d\n",a);

double b=6_3.7_8;

System.out.printf("%f\n",b);

int x=104;

System.out.printf("%d\n",x);

x=0b1101000;

System.out.printf("%d\n",x);

x=0150;

System.out.printf("%d\n",x);

x=0x68;

System.out.printf("%d\n",x);

}

}

Output:-

15546230

63.780000

104

104

104

104


Comments