aspose file tools*
The moose likes Java in General and the fly likes can't be resolved to a type error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "can Watch "can New topic
Author

can't be resolved to a type error

roy neela
Greenhorn

Joined: Mar 26, 2008
Posts: 3
the following code:
class Animal{}
class Dog extends Animal{
public static void main(String a[])
{
Animal [] ani=(new Animal(), new Dog());
.
.
.
}
}
gives the error "Animal.Dog can't be resolved to a type"
why can't the code execute when it's there in theory!!!
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Hi!

Use curly braces for array initialization then it should compile fine:



And you hopefully have the Animal and Dog class in two separate files

Marco
[ March 26, 2008: Message edited by: Marco Ehrentreich ]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19556
    
  16

Originally posted by Marco Ehrentreich:
And you hopefully have the Animal and Dog class in two separate files

Not necessary since they're not both public.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Not necessary since they're not both public.


I just wanted to be sure. You never know

Then the curly braces should be your only problem...
roy neela
Greenhorn

Joined: Mar 26, 2008
Posts: 3
Thank you.... the curly braces solved the problem!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can't be resolved to a type error
 
Similar Threads
cast question
Compile time exceptions vs. Runtime exceptions
Reference Variable Casting?
Generics Help please !
polymorphism