1
public class HalloGUI extends JFrame{
    
    public HelloGUI(String title)
    { 
     // Some explanation about this method 
     super (title);
     /*Why super(title)? What is the usage of super() */

     /* Here some other codes */
    }
    
}

I don't understand the usage of super(title);. I know that title is a parameter of the method super(), but why does ine use it? Do you really need to use it? What is the function of super(title); in this code?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Babo khan
  • 23
  • 4
  • 2
    `super(titel)` will call the constructor `JFrame(String)` . If that call wasn't there it would call `JFrame()` without a title. – M. Deinum Apr 13 '22 at 06:52
  • 7
    Please read https://docs.oracle.com/javase/tutorial/java/IandI/super.html. It's worth noting that Stack Overflow isn't really a good place to learn fundamental language concepts - I'd recommend a good book for that. – Jon Skeet Apr 13 '22 at 06:52
  • @JonSkeet hi Tnx for replying!! Could you please recommend me (name me) a good book ? – Babo khan Apr 13 '22 at 07:20
  • @M.Deinum tnx for respounding ! I really appraciate you ! – Babo khan Apr 13 '22 at 07:21
  • Make up your mind. `titel` or `title`? This code doesn't even compile. – user207421 Apr 13 '22 at 07:21
  • 1
    It's been a long time since I've read any Java books I'm afraid, but there are a *lot* available, so I'd have a look around and read reviews. – Jon Skeet Apr 13 '22 at 07:22
  • 'super(titel)' is a method which calls the constructor JFrame(String)` with titel. am i right ? – Babo khan Apr 13 '22 at 07:24
  • That is correct, but only because that's what you're extending – OneCricketeer Apr 13 '22 at 07:27

0 Answers0