File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Simple example using copyofRange () from Arrays Class won't compile Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Simple example using copyofRange () from Arrays Class won Watch "Simple example using copyofRange () from Arrays Class won New topic
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
    
    6

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
    
  13

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
    
  13

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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Simple example using copyofRange () from Arrays Class won't compile
 
Similar Threads
Help with Arrays
Logic problem or invoke method problem
print invalid selction not working
help with program
Need some help with Java program Airline.java