• Post Reply Bookmark Topic Watch Topic
  • New Topic

incompatible types...  RSS feed

 
vignesh hariharan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



int array can be put into long array right?? then y is it throwing incompatible error.??? help me out.. thanks in advance
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An int[] is not a long[], you cannot convert from one to the other.
 
vignesh hariharan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but int is smaller than long... so why cant a long array hold int array?? this is implicity type cast right???
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, an int can be automatically widened to be a long.

But a long array and an int array are different objects.
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, you could do this..

long [] r = new long [i.length]


then use a for loop to load i's var. into r's
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!