File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
Why this is giving error
Anchit Jindal
Greenhorn
Joined: Feb 03, 2010
Posts: 21
posted
Apr 12, 2010 07:52:21
0
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
Sheriff
Joined: Oct 13, 2005
Posts: 32611
4
posted
Apr 12, 2010 08:01:14
0
The line in question is outside a method.
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
I like...
posted
Apr 12, 2010 17:29:30
0
// 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! :)
I agree. Here's the link:
http://aspose.com/file-tools
subject: Why this is giving error
Similar Threads
String concentation
Sorting arrayLIst containing value objects
invalid key error
using SOAPFaultException
TAke data from page through session
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter