| Author |
Simple example using copyofRange () from Arrays Class won't compile
|
Karen Haq
Greenhorn
Joined: Mar 17, 2010
Posts: 22
|
|
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
Joined: Mar 17, 2010
Posts: 22
|
|
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?
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9946
|
|
|
The error should tell you exactly WHAT symbol can't be found on that line. Can you provide the FULL error message?
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
Karen Haq
Greenhorn
Joined: Mar 17, 2010
Posts: 22
|
|
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].
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24054
|
|
|
The overloaded copyOfRange() methods were introduced in Java 6 (JDK 1.6). If you're using Java 5 or older, they're not there.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Karen Haq
Greenhorn
Joined: Mar 17, 2010
Posts: 22
|
|
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
Joined: Mar 17, 2010
Posts: 22
|
|
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
Marshal
Joined: Jul 08, 2003
Posts: 24054
|
|
|
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
Joined: Mar 17, 2010
Posts: 22
|
|
Ernest...YOU ROCK!! The code complied with no hitches. Thank you so much.
|
 |
 |
|
|
subject: Simple example using copyofRange () from Arrays Class won't compile
|
|
|