Results 1 to 4 of 4
Thread: Inheritance
- 10-09-2013, 02:54 PM #1
Member
- Join Date
- Jul 2013
- Posts
- 14
- Rep Power
- 0
Inheritance
Java Code:class A{ System.out.println("Inside A"); *** } class B extends A{ System.out.println("Inside B"); *** } class C extends B{ System.out.println("Inside C"); *** } public class a{ public static void main(String[] args){ C c = new C(); } }
- 10-09-2013, 03:32 PM #2
Re: Inheritance
Because you can't just put code anywhere you like and expect it to work. Function calls need to be inside a method or static block, except for declarations.
How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
- 10-09-2013, 03:34 PM #3
Re: Inheritance
You can't have statements at class level. They must be inside a constructor, method, a static block or even a non-static block, but not there. Your example would work if you move these to a constructor.
- 10-10-2013, 05:37 PM #4
Member
- Join Date
- Jul 2013
- Posts
- 14
- Rep Power
- 0
Similar Threads
-
Inheritance
By NewToJava_99 in forum New To JavaReplies: 2Last Post: 05-20-2012, 08:03 PM -
Help with inheritance
By waker3210 in forum Java GamingReplies: 6Last Post: 05-19-2012, 08:27 PM -
inheritance
By FREDISCO in forum New To JavaReplies: 2Last Post: 03-27-2012, 02:11 AM -
Inheritance
By new_2_j in forum New To JavaReplies: 5Last Post: 02-20-2011, 05:56 PM -
Inheritance in GUI
By Marty in forum SWT / JFaceReplies: 2Last Post: 05-11-2007, 12:54 AM
Bookmarks