• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

.class error in main

 
Nokomis Sheridan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what I'm doing wrong, but I am getting a .class error in my main method. Could someone please look at it for me?

public class Compact
{
int data[] = new int[100];
int count = 0;

public static void main(String[] args)
{
System.out.println("Compact.java by Chicken Little");
System.out.println();
Compact a = new Compact();
a.removeZeros();
}
public Compact()
{
String fileName = "readme.txt";
FileInput inFile = new FileInput(fileName);
while (inFile.hasMoreTokens())
{
data[count] = inFile.readInt();
count++;
}
}
public void removeZeros(int arrayWithZeros[])
{
for (int i = 0; i < arrayWithZeros.length; i++)
{
if (arrayWithZeros[i] == 0)
{
// Move all elements 1 position
for (int j = i; j < arrayWithZeros.length - 1; j++)
{
arrayWithZeros[j] = arrayWithZeros[j+1];
}
// Then put something at the end, in this case, i want to put a -1
arrayWithZeros[arrayWithZeros.length - 1] = -1;
}
System.out.println(arrayWithZeros[i]);
}
}

}
 
Nokomis Sheridan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did I break the question rule? I didn't think it was that difficult...just for me it was.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Chicken Little"

Welcome to the JavaRanch.

We're a friendly bunch, but we are very serious when it comes to display names. We require display names to be two words: your foirst name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name.

thanks,
Dave
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can please post the error you get? This will give us a better chance of helping you with your problem.

Dave
 
Nokomis Sheridan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops! sorry!

it's fixed now!
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I appreciate it. Do you have an error for us?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic