• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I have a very simple problem...I don't know what it is though

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.util.Random;

class Array_Practice
{
public static void main ( String[] args )
{
}

// METHODS \\
public static void List1()
{
int i;
int List1[] = new List1[20]; <<<<
for (i = 0; i < 20; i++)
{
List1[i] = (int)(Math.random () * 100 + 1);
}
}
public static void List2()
{
int i;
int List2[] = new List2[20]; <<<<
for (i = 0; i < 20; i++)
{
List2[i] = 0;
}
}

public static void Multiply(int[] List1, int[] List2)
{
int i;
int x = 0;
int y = 0;
for (i = 0; i < 20; i++)
{
y = List1[i];
y = y * y;

List2[x] = y;
x++;
}
}

public static void replaceOdd(int[] List2)
{
int i;
for (i = 1; i < 20; i=i+2)
{
List2[i] = 0;
}
}
}
http://www.tvdsb.on.ca/Laurier/Ics3m1/practice/practicing_arrays.html
That is what I'm trying to do, I'm at IV right now. I get one of those "Cannot resolve symbol" errors where you see <<<<. Anyone know why?
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you use "new List1[20]" and "new List2[20]", the compiler is trying to find the classes List1 and List2. They do not exist. Change these to "new int[20]".
Angel
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You can replace that lines with
int List1[] = new int[20];
int List2[] = new int[20];
And your file will get compiled.
 
Cam Ferguson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot. That's been driving me nuts, and I had no idea what was wrong with it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic