class Example
{
public static void main(String args[])
{
char ch; ch = 'X';
System.out.println("ch contains " + ch);
ch++; // increment ch
System.out.println("ch is now " + ch);
ch = 90; // give ch the value Z
System.out.println("ch is now " + ch);
}
}
Predicted Output: ch is now X ch is now Y ch is now Z
*********************************************************
control statements
class Example
{
public static void main(String args[])
{
boolean b; b = false;
System.out.println("b is " + b);
b = true;
System.out.println("b is " + b); // a boolean value can control the if statement if(b)
System.out.println("This is executed.");
b = false;
if(b) System.out.println("This is not executed."); // outcome of a relational operator is a boolean value System.out.println("10 > 9 is " + (10 > 9));
}
}
Predicted output: b is false b is true This is executed 10 > 9 is true
**********************************************************************
math class
class Example {
public static void main(String args[])
{
double x, y, z; x = 3; y = 4;
z = Math.sqrt(x*x + y*y);
System.out.println("Hypotenuse is " +z);
}
}
Predicted Output: Hypotenuse is 5.0
..............................................................................
this was just a basic for more programs get yourself stick to this blog sure you will be master in java.
{
public static void main(String args[])
{
char ch; ch = 'X';
System.out.println("ch contains " + ch);
ch++; // increment ch
System.out.println("ch is now " + ch);
ch = 90; // give ch the value Z
System.out.println("ch is now " + ch);
}
}
Predicted Output: ch is now X ch is now Y ch is now Z
*********************************************************
control statements
class Example
{
public static void main(String args[])
{
boolean b; b = false;
System.out.println("b is " + b);
b = true;
System.out.println("b is " + b); // a boolean value can control the if statement if(b)
System.out.println("This is executed.");
b = false;
if(b) System.out.println("This is not executed."); // outcome of a relational operator is a boolean value System.out.println("10 > 9 is " + (10 > 9));
}
}
Predicted output: b is false b is true This is executed 10 > 9 is true
**********************************************************************
math class
class Example {
public static void main(String args[])
{
double x, y, z; x = 3; y = 4;
z = Math.sqrt(x*x + y*y);
System.out.println("Hypotenuse is " +z);
}
}
Predicted Output: Hypotenuse is 5.0
..............................................................................
this was just a basic for more programs get yourself stick to this blog sure you will be master in java.