File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URGENT

 
Jose Carrillo
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 327
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ February 05, 2004: Message edited by: Marilyn de Queiroz ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic