Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: generics with underclass

  1. #1
    Junior Member
    Join Date
    Nov 2022
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default generics with underclass

    hallo everyone,

    i am learning java, i am trying to learn now the Generics. i have written this program and i dont know why i keep getting error "Command execution failed.".

    public class Mavenproject2 {

    public static void Main(String[] args){
    underclass <Double> taha = new underclass <>(4.0, 5.0);

    taha.display();

    }
    }

    public class underclass <T> extends Superclass{

    T breite;
    T hoehe;

    public underclass(T breite, T hoehe){
    super(4);
    this.breite=breite;
    this.hoehe=hoehe;
    }

    public void display(){
    System.out.println("breite = " + this.breite + "hoehe" + this.hoehe + "ecken" + super.getEcken());
    }

    }
    public abstract class Superclass {
    Integer Ecken;

    public Superclass(Integer Ecken){
    this.Ecken=Ecken;
    }
    public Integer getEcken(){
    return Ecken;
    }

  2. #2
    Junior Member
    Join Date
    Oct 2022
    Location
    Pune
    Posts
    26
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: generics with underclass

    The problem is with your Main function. You should have:

    public static void main(String[] args)

    not

    public static void Main(String[] args)

Similar Threads

  1. [SOLVED] Generics
    By stewbond in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 17th, 2013, 04:31 PM
  2. Need some help with Generics
    By bankston13 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 5th, 2012, 03:06 PM
  3. Generics.
    By Kumarrrr in forum Java Theory & Questions
    Replies: 1
    Last Post: December 6th, 2011, 06:53 PM
  4. Generics
    By Kerr in forum Collections and Generics
    Replies: 2
    Last Post: May 19th, 2011, 06:44 PM
  5. Generics
    By _lithium_ in forum What's Wrong With My Code?
    Replies: 21
    Last Post: December 6th, 2010, 07:08 PM

Tags for this Thread