By: On: sun Jun 30 12:54:15 EDT 2013220 4
In the below code , it gives error at compile time "Possible lose of precision".Please provide me reason for this.

You are watching: Possible loss of precision error in java

import java.util.Scanner;class one public static void main(String args<>) Scanner sr = new Scanner(System.in); int i; long a=5; long arr<> = brand-new long; for(i=0;i arr=sr.nextInt(); for(i=0;i System.out.print(arr+" ");
2

int the line:long arr<> = brand-new long; friend are specifying the dimension of array ,which should be int type,and you are passing a as long type.0
By: On: Mon Jul 01 02:47:08 EDT 201301470147
*
Are girlfriend Satisfied :2Yes2No
when float within the size parameter get rounded, the causeg a loss of precision.0
By: On: Mon Jul 01 03:12:53 EDT 201303920392
*
Are you Satisfied :1Yes3No

rishi ns am no satisfied v your answer. Because this password is operation successfully. Course aj public static void main(String args<>) lengthy arr<> = brand-new long<5>;
0
By: On: Mon Jul 01 03:36:09 EDT 20132204
Are friend Satisfied :1Yes0No
obviously it need to be....

See more: Which Improves Air Circulation In Forced-Air Heating, A, Radiation B, Conduction, C, Convection

long arr<> = brand-new long<5>; while creating the selection of long kind the size have to be in int, in range class"s constructor the size parameter is identified as int, and whenever you room passing long a ,then int is not qualified to store the lengthy value,because it"s range exceeds the int range,that"s why lose of precision error wake up .. If you create 5 directly it is thought about as int ,so no problem..
1
By: On: Mon Jul 01 06:42:28 EDT 201301470147
*
*
*
*
*
*