Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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
Posts: 12871
62
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
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • 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
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • 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.
 
Hang a left on main. Then read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic