Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes URGENT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "URGENT" Watch "URGENT" New topic
Author

URGENT

Jose Carrillo
Greenhorn

Joined: Nov 13, 2003
Posts: 17
Hi well I creating a program with two classes and one of those classes is a test class which test the other class that basically is an ADT of giant number of 100 digits. but I'm having a problem and I do not know what is it here is my code:
public class GiantNumber
{
private short[] digitsArray;
public GiantNumber(int value)
{
this();
int x = 99;
while (value !=0);
{
digitsArray[x] = (short) (value % 10);
value = value /10;
x--;
}
}
public GiantNumber ()
{
for (int j = 0; j < 100; j++)
{
digitsArray [j] = 0;
}
}
public void add(GiantNumber otherNumber)
{
int a = 0;
int b = 0;
for(int y = 99; y >= 0; y--)
{
this.digitsArray[y] += otherNumber.digitsArray[y] + a;
this.digitsArray[y] = (short) b;
b = this.digitsArray[y] % 10;
a = this.digitsArray[y] / 10;
}
}
public void substract(GiantNumber otherNumber1)
{
GiantNumber a = new GiantNumber(20);
GiantNumber b = new GiantNumber(15);
a.substract(b);
}
public void greater()
{
}
public boolean equals()
{
return true;
}
public String toString();
{
}
}
public class TestGiantNumber
{
public static void main(String[] args)
{
TestGiantNumber GiantNumber = new TestGiantNumber();
GiantNumber a = new GiantNumber(2);
GiantNumber b = new GiantNumber(2);
a.add(b);
}
public TestGiantNumber()
{
}
}
and when I run the program the error is:
java.lang.ClassFormatError: GiantNumber (Code attribute is absent in method that is not abstract or native)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at TestGiantNumber.main(TestGiantNumber.java:20)
Exception in thread "main"
leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
I see that you have two public classes in your program.
public class GiantNumber
and
public class TestGiantNumber
Only one class per java source file can be "public"


Thanks, leo
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Jose,
After 21 posts you still didn't use code tags and you used the subject line of "URGENT" (in all upper case letters).

Do you know how many people will avoid your post because of these two things?


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10

[ February 05, 2004: Message edited by: Marilyn de Queiroz ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: URGENT
 
Similar Threads
FileNotFoundException
forte for java
what is the problem with this code
Showing Images in Splash Screen
java BigNumber 2