Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
Why this is giving error
Anchit Jindal
Greenhorn
Posts: 21
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The code at
http://pastebin.com/diz9Q9sm
is giving the following error:
B.java:17: <identifier> expected
b.print();
1 error
Please explain the reason
Thanks a lot...
Campbell Ritchie
Marshal
Posts: 79177
377
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The line in question is outside a method.
David Newton
Author
Posts: 12617
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
// Demo of Covariant return type // method print() in B class is returning object of type A which is subclass of Object class whose object is being returned // by print method in A class class A { Object obj; public Object print() { System.out.println("Hello A Class"); return obj; } } class B extends A { A a = new A(); B b = new B(); b.print(); // <-- here public static void main(String[] args) { } @Override public A print() { System.out.println("Hello B Class"); return a; } }
Please just paste your code into your messages; the syntax highlighting is good enough and saves us a step. Thanks! :)
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
TAke data from page through session
invalid key error
Sorting arrayLIst containing value objects
using SOAPFaultException
String concentation
More...