Category: Java

How to check if a string contains  a digit and return true 0

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

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

JLabel -example 0

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.   /** * * @author Eric * Email:kawi3462@gmail.com * Site:www.techoverload.net */ import java.awt.FlowLayout; import javax.swing.JFrame;...

setEnabled 0

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

ImageIcon 0

Add ImageIcon to a JLabel and center it

/** * * @author Eric * Email:kawi3462@gmail.com * Site:www.techoverload.net */ import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.ImageIcon; public class JLabelImageIcon extends JFrame { public JLabelImageIcon() { super("JLabel with Image Icon Example"); setSize(400,400); setLayout(new...

Write a  function that takes an array of integers as an argument and returns a value based on the sums of the even and odd numbers in the array. 0

Write a function that takes an array of integers as an argument and returns a value based on the sums of the even and odd numbers in the array.

Write a function that takes an array of integers as an argument and returns a value based on the sums of the even and odd numbers in the array. Let X = the sum of...

How to override Java Methods 0

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

How to overload java methods by changing data type 0

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.   public class MethodOverload { public void sumNumbers(int num1,int num2) { int...

How to overload java methods by changing number of arguments 0

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

What is Aggregation in Java 0

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