Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By KevinWorkman

Thread: Herritage issue

  1. #1
    Games2Design is offline Member
    Join Date
    Sep 2012
    Posts
    44
    Rep Power
    0

    Default Herritage issue

    Java Code:
    class TestABC{
        public static void main(String[]args){
    	L p=new L();
        }
    }
    
    class D{
        public void write(int i){
    	System.out.println(i);
        }
    }
    
    class L extends D{
        int b =2;
    
        write(b);
    }
    TestABC.java:16: error: invalid method declaration; return type required
    write(b);



    Why does this not work?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,689
    Rep Power
    8

    Default Re: Herritage issue

    What doesn't work about it?

    Hint: statements have to be inside a method or constructor. Recommended reading: Lesson: Classes and Objects (The Java™ Tutorials > Learning the Java Language)
    Games2Design likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Games2Design is offline Member
    Join Date
    Sep 2012
    Posts
    44
    Rep Power
    0

    Default Re: Herritage issue

    I will do that. Thank you for fast reply :)

Similar Threads

  1. GUI Issue
    By Nakinsige in forum New To Java
    Replies: 1
    Last Post: 02-22-2012, 10:17 AM
  2. Regular Expression issue and setName() method issue
    By geforce in forum New To Java
    Replies: 2
    Last Post: 01-30-2012, 03:33 AM
  3. CMD Issue
    By Gee in forum New To Java
    Replies: 4
    Last Post: 01-20-2012, 11:07 AM
  4. JSP issue
    By RamaLakshmi in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 01-21-2011, 01:55 PM
  5. PDF Box issue
    By jazz2k8 in forum Advanced Java
    Replies: 0
    Last Post: 03-20-2009, 11:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •