Monday, February 25, 2008


Java Example : Sum of Two Numbers

A very simple example to add 2 numbers. Use Integer.parseInt to convert the value in integer. By default it will consider the value as string.

public class AddNumbers{
public static void main(String[] args) {
System.out.println("Addition of two numbers!");
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int sum = a + b;
System.out.println("Sum: " + sum);
}
}


Friday, February 22, 2008


Remove Title Bar : Java Swing Code

This java swing example explain you how to remove title bar from the frame. Here is the example code :

import
javax.swing.*;
public class RemoveTitleFrame{
public static void main(String[] args) {
JFrame frame = new JFrame(Frame With No Title Bar);
frame.setUndecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,400);
frame.setVisible(true);
}
}