Reading a text file in Java

For reading a file we have to create a FileReader object. Then we create BufferedReader object of FileReader. If file not found FileReader constructor throws FileNotFoundException. If br.readLine() is not able to read source file it throws IOException.

Continue Statement in Java

Continue statement can used with iteration statement (for,while,do while). In for statement continue transfer the control to updation of loop variable. In while and do while statement continue transfer control to condition of the loop. Example

When value of i is 5 then continue statement is executed and control is transferred to beginning of … Read more

How to remove special characters from a string in java

Here we will see How to remove special characters from a string in java. Special characters are like & $ % @ ! < > etc that may occurs in string. To remove this we see programs how to remove special characters in java In Java String is a class that provides different constructors and … Read more

Login page in awt applet Java

Creating Login page in awt applet is easy. Here we are not using any layout. Login page contains two label, one textfield , one password field and two buttons. Steps by step process to develop this program is as below Declare Label, JTextField, JPasswordField and Button Inside init() create object for JLabel, JTextField and JPasswordField … Read more

Method Overloading with examples in Java

what is method overloading in java? In Java programming, Defining two or more methods with the same name with different parameter list are called Method Overloading in Java. Like void add(int a,int b);void add(double a, double b);void add(String a,String b);int add(int a,int b,int c); In method overloading, the method return type may be different. The … Read more

What is Java Pi | Pi in Java | Math.PI Java Value and Example

Pi (π) is a well-known mathematical constant whose value is 22/7 or 3.14159265359. Programming languages also use this constant for mathematical calculation. Here we discuss PI with respect to the Java programming language. In Java PI is defined as a field in java.lang.Math class. It is defined as static double PI and described as The double value … Read more

JLabel in Java Swing with Method Constructors and Examples

JLabel in Java Swing is an object that is used to display text and images in a Frame. Jlabel uses to display information, show different messages, and make the frame interactive and readable. JLabel class declaration public class JLabel extends JComponent implements SwingConstants, Accessible JLabel extends JComponent and implements SwingConstants and Accessible Interfaces. JLabel Constructors … Read more

Applet Life Cycle in Java with Example

Applet in Java Applet in Java is a special Java program that are primarily used in a internet programming. Applet Life Cycle is very important to know in Java Applet Programming.  As we have already seen how to run program from command prompt, but there were no GUI. To provide Graphical user interface(GUI) Java Applet … Read more

Simple java program to add two numbers

java program to add two numbers is a very simple program. It is required by learners How can we add two numbers. We will start with simple addition and try to cover additional things here. Simple java program to add two numbers Steps to add two numbers Store two numbers in two variables Add both … Read more

Java swing login form with database connection source code download

Here we will develop the Java swing login form with database connectivity. We considered a small example with student details to log in From Java Swing and redirect to another frame after login. Java swing login form with database connection in Netbeans Here we have created a swing login form in java and connected that … Read more