String class in java represent character strings .Just like other constants Strings values cannot be changed.String objects  can be shared and they are immutable.Example of a  string in java String str=”Eric loves programming”. Today we are going to use different String class methods to write a method that returns true if a string contains a […]

Read More


Creating a JLabel with Text Example

Below code creates a Simple JLabel with Text Example using JLabel() constructor method.Note that JLabel class has several methods.  

Output:

Read More


Check whether a JLabel is Enabled or Visible.

JLabel.setEnanbled() methods enable a JLabel or make it visible in it container.If you set false, the JLabel is not visible and if set truth, the JLabel is visible. Below code creates two JLabels, one is enabled and the other is not enabled.

Read More


Add ImageIcon to a JLabel and center it

OutPut  

Read More


Overriding java methods happen in a case where a child class implements a method that is contained in super class.The main use of overriding is to provide a new implementation of a method. Overriding Java methods can take place if only:- Child class and parent class are in IS-A inheritance. Child class method should have […]

Read More


How to overload java methods by changing data type

Below code shows how to overload java method by changing data type.See also Overloading java methods by changing the number of arguments.  

Output

Read More


Aggregation in Java is very important because it makes code reusable.Think of a scenario where you’re creating a school-based management system.Student name, id, age are mandatory to be a caption in the system.Think of a student address.Student address will contain student state, city, zipcode etc. Aggregation in Java Example code  

Read More