Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Thursday, November 25, 2010

for DIT 11 Irregular

this is a sample program to compute two numbers and get the sum.

i hope you learn and enjoy....

import java.io.*;
import java.util.Scanner;

public class Computation
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
int num1,num2,sum=0;
System.out.print("Enter first number:");
num1=input.nextInt();

System.out.print("Enter second number:");
num2=input.nextInt();

sum=num1 + num2;

System.out.println("The sum is:" + sum);
}
}

Tuesday, September 21, 2010

Java Tutorial

please visit this website to advance learning .....http://www.kodejava.org

next time i will be post another java programs..

Sunday, April 18, 2010

String in Java

he String class represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class.

Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. For example:

     String str = "abc";  
sample program.

import java.io.*;

public class stringsample
{
public static void main(String args[])
{
System.out.print("Hello World");
System.out.print("Welcome to my String Java program");

}
}

Monday, March 29, 2010

Declaring variables in java

to declare a variable in java we use the data type.
example:
int a;
int a=5;
float rph=1.2;
char s;
char let='A';
String s[]={"Hello", "World"};