• Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple example using copyofRange () from Arrays Class won't compile  RSS feed

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm just trying to understand how to use this method. I keep getting "cannot find symbol" for fcseats = Arrays.copyofRange(schart,0,4) when I compile, why am I getting this error? I verified parameters in the API.






 
Karen Haq
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me clarify what I'm trying to do here,

I want to populate fcseats [] by copying the values from the sc[]. How do I do this?
 
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error should tell you exactly WHAT symbol can't be found on that line. Can you provide the FULL error message?
 
Karen Haq
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cannot find symbol - method copyofRange(boolean[], int, int)


I want to copy values stored at index [0] to [4] of sc[9] into fcseats[4].
 
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The overloaded copyOfRange() methods were introduced in Java 6 (JDK 1.6). If you're using Java 5 or older, they're not there.
 
Karen Haq
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!! I'll now verify which version of Java my system was preinstalled with. I'll get back to you if I have more questions about this.

But more importantly, is my attempt at using copyofRange() method correct?

 
Karen Haq
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I actually have the right version:

Last login: Tue Apr 27 08:45:40 on ttys000
karen-haqs-imac:~ karenhaq$ java -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04-248-9M3125)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01-101, mixed mode)
karen-haqs-imac:~ karenhaq$


Why did I get the compile error for the copyofRange()??
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking a little more closely at your code, I see "copyofRange()" whereas the name of the method is copyOfRange(). Letter case is significant, and method names always (by convention) capitalize each word.
 
Karen Haq
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest...YOU ROCK!! The code complied with no hitches. Thank you so much.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!