473,386 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

extending class that is not in a packed

Hello all,
I have this problem.
I have a class that is not in a package
lets say
public class Class1 {
public Class1() {
....
}
public void DoSomething(){
....
}

}
and class Class2 that is
package a;
class Class2{
public Class2() {
....
}
public void DoSomething2(){
....
}

}

My question is
How can Class2 extend Class1 since Class1 is not part of a package?
Regards
Niki
Jul 17 '05 #1
3 1489
Niki Iv wrote:
Hello all,
I have this problem.
I have a class that is not in a package
lets say
public class Class1 {
public Class1() {
....
}
public void DoSomething(){
....
}

}
and class Class2 that is
package a;
class Class2{
public Class2() {
....
}
public void DoSomething2(){
....
}

}

My question is
How can Class2 extend Class1 since Class1 is not part of a package?
Regards
Niki


I noticed that your Class1 isn't in ANY package. I found this type of
coding to compile fine under Java 1.1, but it seems that since 1.2+ it's
generally a good idea to put all classes in packages. So, assuming that
Class1 resides in package x, then your Class2 definition would be:

public class Class2 extends x.Class1 {
...
}
Jul 17 '05 #2
Import the class you want to extend

"Niki Iv" <ni*****@abv.bg> wrote in message
news:jm********************************@4ax.com...
Hello all,
I have this problem.
I have a class that is not in a package
lets say
public class Class1 {
public Class1() {
....
}
public void DoSomething(){
....
}

}
and class Class2 that is
package a;
class Class2{
public Class2() {
....
}
public void DoSomething2(){
....
}

}

My question is
How can Class2 extend Class1 since Class1 is not part of a package?
Regards
Niki

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.770 / Virus Database: 517 - Release Date: 9/27/2004
Jul 17 '05 #3
How can I 'import' classes in java
This concept is new to me. Now I am using reflect to extend this class
but this obviously is not the best solution?
On Wed, 29 Sep 2004 21:00:24 -0400, "Hal Rosser"
<hm******@bellsouth.net> wrote:
Import the class you want to extend

"Niki Iv" <ni*****@abv.bg> wrote in message
news:jm********************************@4ax.com.. .
Hello all,
I have this problem.
I have a class that is not in a package
lets say
public class Class1 {
public Class1() {
....
}
public void DoSomething(){
....
}

}
and class Class2 that is
package a;
class Class2{
public Class2() {
....
}
public void DoSomething2(){
....
}

}

My question is
How can Class2 extend Class1 since Class1 is not part of a package?
Regards
Niki

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.770 / Virus Database: 517 - Release Date: 9/27/2004


Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

56
by: ccwork | last post by:
Hi all, Here is a sample code segment: .... typedef PACKED struct { union { PACKED struct { char red:1;
0
by: yccheok | last post by:
I try to write a c implementation of java abstract class which serve the same purpose. however, I feel that there might be some potential holes in the future especially when I plan to scale up this...
4
by: Matt | last post by:
Hi, I've been thinking about how to do this, but can't think of a solution. I have a class that is derived from System.Web.UI.WebControls.DataGrid which works a treat, but I'd like to extend...
3
by: Amaryllis | last post by:
Hi again, I'm new to the world of communicating between VB.NET and AS/400, so I've been posting a lot of questions lately since no one else in the company has done anything like this before. ...
3
by: Marco Meoni | last post by:
Hi all! I've a problem with a C++ class that has to be included in a python application. One way to do it is Extending and Embedding the Python Interpreter Now i have 2 questions 1) Is there a...
3
by: parag.kanade | last post by:
I have a packet structure which has a field of Integer arrays, that is packed struct { int a; char b; int count; }foo; I need to initialize all the entries of count to a particular value,
5
by: vbgunz | last post by:
Hello everyone. I own two books. Learning Python and Python in a nutshell. When cross referencing the two books to try and clarify the ideas behind extending methods and delegates, this is where...
15
by: Daniel Rudy | last post by:
What is the difference between packed and unpacked structs? -- Daniel Rudy Email address has been base64 encoded to reduce spam Decode email address using b64decode or uudecode -m Why...
9
by: Sikandar | last post by:
Hi, I am beginner in C. Pls let me know what is packed array in C. Where is it used? Thanks, Sikandar
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.