title: Possible loss of precision when using long
body: <p>I am still new to Java, below given program was working absolutely fine until i changed all the int data types to long data types. Now it is giving me a loss of precision error and i don't understand why? I have changed all the data types to long, and yet i am getting this error. Please help.    </p>
  
  <pre><code>public class Solution {
  
      public static void main(String[] args) {
          long i,j,great=0,gpos=0,k=1,temp=0;
          Scanner in = new Scanner(System.in);
  
          long n = in.nextLong();
          long[] scores = new long[n];
  
          for(long scores_i = 0; scores_i &lt; n; scores_i++){
              scores[scores_i] = in.nextLong();
          }
  
          long m = in.nextLong();
          long[] alice = new long[m];
  
          for(long alice_i = 0; alice_i &lt; m; alice_i++){
              alice[alice_i] = in.nextLong();
          }
  
          long rank[] = new long[n];
  
          for(j=0;j&lt;n;j++){
              great = 0;
              for(i=0;i&lt;n;i++){
                  if(rank[i]!=0){
                      continue;
                  }
                  if(great&lt;scores[i]){
                      great=scores[i];
                      gpos=i;
                  }
              }
  
              if(temp==great){
                  k--;
                  rank[gpos]=k;
                  k++;
              }
              else{
                  rank[gpos]=k;
                  temp=great;
                  k++;
              }
          }
  
          for(i=0;i&lt;m;i++){
              for(j=0;j&lt;n;j++){
                  if(alice[i]&gt;scores[j]){
                      System.out.println(rank[j]);
                      break;
                  }else if(alice[i]==scores[j]){
                      System.out.println(rank[j]);
                      break;
                  }else if(j==(n-1)){
                      System.out.println(rank[j]+1);
                      break;
                  }
              }
  
          }
  
          in.close();
      }
  }
  </code></pre>
  
  <p>Here is the error report that i keep getting:</p>
  
  <pre><code>Solution.java:11: error: possible loss of precision
          long[] scores = new long[n];
                                   ^
    required: int
    found:    long
  Solution.java:14: error: possible loss of precision
              scores[scores_i] = in.nextLong();
                     ^
    required: int
    found:    long
  Solution.java:18: error: possible loss of precision
          long[] alice = new long[m];
                                  ^
    required: int
    found:    long
  Solution.java:21: error: possible loss of precision
              alice[alice_i] = in.nextLong();
                    ^
    required: int
    found:    long
  Solution.java:24: error: possible loss of precision
          long rank[] = new long[n];
                                 ^
    required: int
    found:    long
  Solution.java:29: error: possible loss of precision
                                  if(rank[i]!=0){
                                          ^
    required: int
    found:    long
  Solution.java:32: error: possible loss of precision
                                  if(great&lt;scores[i]){
                                                  ^
    required: int
    found:    long
  Solution.java:33: error: possible loss of precision
                                          great=scores[i];
                                                       ^
    required: int
    found:    long
  Solution.java:40: error: possible loss of precision
                                  rank[gpos]=k;
                                       ^
    required: int
    found:    long
  Solution.java:44: error: possible loss of precision
                                  rank[gpos]=k;
                                       ^
    required: int
    found:    long
  Solution.java:52: error: possible loss of precision
                                  if(alice[i]&gt;scores[j]){
                                           ^
    required: int
    found:    long
  Solution.java:52: error: possible loss of precision
                                  if(alice[i]&gt;scores[j]){
                                                     ^
    required: int
    found:    long
  Solution.java:53: error: possible loss of precision
                                          System.out.println(rank[j]);
                                                                  ^
    required: int
    found:    long
  Solution.java:55: error: possible loss of precision
                                  }else if(alice[i]==scores[j]){
                                                 ^
    required: int
    found:    long
  Solution.java:55: error: possible loss of precision
                                  }else if(alice[i]==scores[j]){
                                                            ^
    required: int
    found:    long
  Solution.java:56: error: possible loss of precision
                                          System.out.println(rank[j]);
                                                                  ^
    required: int
    found:    long
  Solution.java:59: error: possible loss of precision
                                          System.out.println(rank[j]+1);
                                                                  ^
    required: int
    found:    long
  17 errors
  </code></pre>