I have an assignment with a class called CircleCalculatorA that calculates the third side as well as all the angles of a triangle. This is the constructor:
We then need to write a class that extends this one and calculates the area and perimeter. This is what I have so far for the class.
In perimeter = a + b + c;, a, b, and c are underlined in red and it says that "field is not visible". I have no idea what this means. Ever since we've been doing inheritance I've been going insane. I can't stand Java anymore.
iam having the same problem with inheritance when i use the ecllipse ide
when the above code is run in eccllipse it give the folowing errors i get the following errors
java.lang.NoClassDefFoundError: A (wrong name: a) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) Exception in thread "main"
but when i use the jdk from cmd it works fine .
i believe i need to do some setting changes in ecllipse but i dont know wht to do
Adam, if the class you were given, TriangleCalculatorA, has accessor methods for the sides (getA, getB, getC), you can use those instead of referencing the variables directoy, assuming they have a visible scope (generally public).
San, I assume you don't specify a package for your classes. If not, perhaps Eclipse is having trouble realizing they are in the same (non-existent) package. It's always a good idea to put your classes into named packages.
san ch, the error message gives you a hint as to what is wrong:
Notice that it indicates that the class named "A" cannot be found. The name "a" was found, though. This typically means that the name of the class and the name of the file it is saved in do not match. Remember that Java is case-sensitive, so the file name HAS to match EXACTLY, especially when it comes to capitalization. This means that "public class A" must be saved in a file named "A.java". Notice that the capitalization is the same in both cases.