I have a package with a
public abstract class Player { /*...*/ }
and these
public abstract class GamePlayer extends Player { /*...*/ }
public abstract class TournamentPlayer extends Player { /*...*/ }
public abstract class ...
|
What is the reason that in Java, a member with a "protected" modifier can not only be accessed by the same class and by subclasses, but also by everyone in the ... |
I was curious to understand what's happening here.( a protected member being accessed outside the package through a subclass )
I know for classes outside the package, the subclass ... |
package a;
class hello{
}
package b;
import a.*;
class hello extends hello{
}
please tell me what is the result??
|
I'm writing a very basic app, extending the Swing JFrame. What are the differences between making an explicit reference:
public class LineTest extends javax.swing.JFrame {
...
or importing the class beforehand:
import javax.swing.JFrame;
public class LineTest ...
|
I'm using an (open-source) API in my Java project and referencing interfaces from it. One interface (Foo) is used extensively both in the API and in projects that use it. For ... |
I have some classes that I need to be able to extend within the same package. But I don't want for anyone else outside of my package to extend my classes. ... |
|
hi all, i have a doubt on package concept. That is, i have created the package in one directory and saved it. Then, i have created the another one program and i tried to extend the class which resides on the package. but the package in one directory and the program or class is in another directory, and i used to ... |
I have two questions, 1) I have an assignment in which I am supposed to extend a class I created in a previous assignment. But when I create the class and have it extend the old class, I get two errors; cannot resolve symbol: constructor Person ()in class Person, and Object ()in Java.lang.object is not defined in a public class or ... |
Suppose I have a directory C:\Java with a subdirectory pkgA. Now I code two JAVA files Test1.java and Test2.java, the former in C:\Java and the latter in C:\Java\pkgA. The codes are below: //Test1.java in C:\Java import pkgA.*; public class Test1 { public static void main(String[] args) { Test3 test = new Test3(); test.method1(); test.method2(); } class Test3 extends Test2 { void ... |
Try adding the @Override annotation to C2.met1. You will see it will fail. The reason is simple. C1.met1 has default (package) access. C2 is in a different package. That means that C2 does not have access to C1.met1, and it doesn't override the method but instead hides / shadows it. It's odd indeed, but you can compare it to "overriding" a ... |
|
Don't put anythink under where you install your JDK. All your code and 3rd part libs should be outside the JDK directory. If you have C:\proj\pack1 C:\proj\pack2 then your classpath must include C:\proj. [Javapedia: Classpath|http://wiki.java.net/bin/view/Javapedia/ClassPath] [How Classes are Found|http://java.sun.com/j2se/1.5.0/docs/tooldocs/findingclasses.html] [Setting the class path (Windows)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html] [Setting the class path (Solaris/Linux)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html] [Understanding the Java ClassLoader|http://www-106.ibm.com/developerworks/edu/j-dw-javaclass-i.html] java -cp .; YourClassName ... |
|
Hello to all.. I have the file Car.java that is in package Vehicle in C:\Vehicle, and a second file Cabrio.java that is in package Vehicle.CarPack in C:\Vehicle\CarPack. I want the class Cabrio to inherit class Car but when i write " import Vehicle.*; " in class Cabrio I get a " package Vehicle does not exist. " message. How can I ... |
Thank you. I was able to compile and run the code: I had to change my commands a bit. I used the following commands Compile javac -d C:\ C:\SunJava\Shape.java javac -d C:\ C:\SunJava\Rectangle.java javac -d C:\ C:\SunJava\Square.java javac -d C:\ C:\SunJava\CompareArea.java Run java SunJavaClass.CompareArea If I use packages, do I always need to compile/run from the root? Please do let me ... |
I then tried to inherit that class through the beans without importing the package and it gave me an error. And when I tried to import it, it gave the same error. it still couldn't find it. Can someone tell me how classes within a package may inherit from a class within the same package? |
|