error: cannot find symbol within package??

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
User avatar
jon80
Posts: 24
Joined: Thu May 28, 2009 10:03 am

error: cannot find symbol within package??

Post by jon80 »

"Instance methods can be overridden only if they are inherited by the subclass.
A subclass within the same package as the instance's superclass can override
any superclass method that is not marked private or final.

A subclass in a
different package can override only those non- final methods marked pub-lic or protected (since protected methods are inherited by the subclass)."

SCJP book http://www.amazon.co.uk/Certified-Progr ... 933&sr=8-1 P.106

I am trying to provide an example of this, however, I am stuck at trying to create classes within the same package:

Code: Select all

package mammals;

public class Mammal
{
	public Mammal() {}
}

Code: Select all

package mammals;
public class OrdinaryMan extends Mammal
{
	public OrdinaryMan()
	{}
}
Error error: cannot find symbol
public class OrdinaryMan extends Mammal.

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Jon\workspace\JavaDev\myCode Snippets>cd mammals

C:\Documents and Settings\Jon\workspace\JavaDev\myCode Snippets\mammals>tree
Folder PATH listing
Volume serial number is 0006EFC4 D80F:8634
C:.
No subfolders exist


C:\Documents and Settings\Jon\workspace\JavaDev\myCode Snippets\mammals>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634

Directory of C:\Documents and Settings\Jon\workspace\JavaDev\myCode Snippets\ma
mmals

11/01/2012 13:14 <DIR> .
11/01/2012 13:14 <DIR> ..
11/01/2012 13:14 194 Mammal.class
11/01/2012 13:14 66 Mammal.java
11/01/2012 13:15 91 OrdinaryMan.java
3 File(s) 351 bytes
2 Dir(s) 32,598,069,248 bytes free

C:\Documents and Settings\Jon\workspace\JavaDev\myCode Snippets\mammals>

C:\Documents and Settings\Jon\workspace\JavaDev\myCode Snippets>tree
Folder PATH listing
Volume serial number is 00740065 D80F:8634
C:.
├───CastingExample
├───DatabaseReadTest
├───food
├───icons
├───JApplet
├───JAR File Deployment example
│ └───horstmann
│ └───samples
├───Logging
│ ├───.settings
│ ├───bin
│ │ └───logging
│ └───src
│ └───logging
├───mammals
├───OverloadingVsOverriding
├───projecteuler.net
└───Serialization

C:\Documents and Settings\Jon\workspace\JavaDev\myCode Snippets>java -version
java version "1.7.0_04-ea"
Java(TM) SE Runtime Environment (build 1.7.0_04-ea-b06)
Java HotSpot(TM) Client VM (build 23.0-b09, mixed mode, sharing)

When using Eclipse IDE a similar structure is being configured, yet I have no issues compiling. Please contact me if you require a copy.

NOTE: No way of uploading attachments to this forum seems to be available.

Any ideas please?

[/b][/code][/url]
Jon
Post Reply