Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Cam Ferguson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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?
 
Angel Dobbs-Sciortino
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • 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
 
Amit More
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks a lot. That's been driving me nuts, and I had no idea what was wrong with it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic