if statement is a conditional statement in programming. In this statement we are using the conditonal operators. this is true or false only. if the conditional statement is true the program execute the true statements, if the conditional statement is false the program execute the false statements.
sample program:
this program will show to you if the grade of students is greater than 75 the program will show message "Your passed" else "Sorry your Failed".
import java.io.*;
public class sample
{
public static void main(String args[])
{
int average=75;
if(average>=75)
{
System.out.print("Your Passed");
}
else
{
System.out.print("Your Failed");
}
}
}
Sunday, April 4, 2010
Conditional Operators
Conditional operators are used in programming to perform condition in a program to execute statement.
1. (>) greater than
2. (<) Less than
3. (>=) Greater than equal
4. (<=) Less that equal
5. (==) Equal
6. (!=) not equal
next lesson is if statement.
1. (>) greater than
2. (<) Less than
3. (>=) Greater than equal
4. (<=) Less that equal
5. (==) Equal
6. (!=) not equal
next lesson is if statement.
Keywords in Java programming
The following keywords in java programming are:
abstract assert boolean break byte case catch char class
const continue default do double else enum extends final
finally float for goto if implements import instanceof
int interface long native new package private protected public
return short static strictfp super switch synchronized this throw
throws transient try void volatile while
it is used in java programming to implement a code and generate a function to have a correct statement.
abstract assert boolean break byte case catch char class
const continue default do double else enum extends final
finally float for goto if implements import instanceof
int interface long native new package private protected public
return short static strictfp super switch synchronized this throw
throws transient try void volatile while
it is used in java programming to implement a code and generate a function to have a correct statement.
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"};
example:
int a;
int a=5;
float rph=1.2;
char s;
char let='A';
String s[]={"Hello", "World"};
Labels:
data type,
java,
programming,
variable declaration
Types, Values, and Variables
the java data types are:
--> integer
-->float
-->character
--> String
--> double
the values accept by the following data types are.
integer - 1,2,3,4,5,6,789,78
float - 1.2,1.0,3.8..... etc
character - 'A','a' ,'t' ,'h' ....
String - "Hello", "jaypee"
double - 1.22,1.04,1.90 .....
--> integer
-->float
-->character
--> String
--> double
the values accept by the following data types are.
integer - 1,2,3,4,5,6,789,78
float - 1.2,1.0,3.8..... etc
character - 'A','a' ,'t' ,'h' ....
String - "Hello", "jaypee"
double - 1.22,1.04,1.90 .....
Hello world using java
this is a simple program in java.
import java.io.*;
public class helloworld
{
public static void main(String args[])
{
system.out.print("Hello World");
}
}
import java.io.*;
public class helloworld
{
public static void main(String args[])
{
system.out.print("Hello World");
}
}
Subscribe to:
Posts (Atom)