set java path system variable

How to set java path system variable in Windows 10

Today am going to show you how to set java path system variable in Windows 10. You require the following for this article. Windows 10 Installed on your computer. JDK 11.0.1 Open Advanced System Settings in Windows 10. At the bottom-left of your screen, Enter Advanced…

How to check if a string contains a digit and return true in Java

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…

JLabel -example

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:

setEnabled

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.

ImageIcon

Add ImageIcon to a JLabel and center it

OutPut  

java function

Write a java function that accepts an integer array and returns 1 if it is a centered array, otherwise it returns 0.

An array with an odd number of elements is said to be centered if all elements (except the middle one) are strictly greater than the value of the middle element. Note that only arrays with an odd number of elements have a middle element. Write…

How to override Java Methods

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…

How to overload java methods by changing data type

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

How to overload java methods by changing number of arguments

How to overload java methods by changing number of arguments

The main reason why programmers overload methods are for easier readability.Think of a scenario where you have a method to multiply two numbers and another method multiply three numbers.These methods will have different names.Instead of using different names, java overloading allows us to use the…

What is Aggregation in Java

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.…