A Program Using Switch-Case To Print Weekdays
class week
{
public static void main(String arg[])
{
int a;
a=Integer.parseInt(arg[0]);
switch(a)
{
case 0:
System.out.println("Monday");
break;
case 1:
System.out.println("Tuesday");
break;
case 2:
System.out.println("Wednesday");
break;
case 3:
System.out.println("Thursday");
break;
case 4:
System.out.println("Friday");
break;
case 5:
System.out.println("Satday");
break;
case 6:
System.out.println("Sunday");
break;
default:
System.out.println("Invalid Input, enter Input between 0-6: ");
break;
}
}
}
Use notation:
C:\>cd\sdk\jdk\bin Press Enter
* C:\>javac week.java Press Enter
* C:\>;java week 0 Press Enter

Two Programs Showing Difference Between While and Do-While Statements
Using While Statement:
class whil
{
public static void main(String[] arg)
{
int i=0;
while(i!=5)
{
System.out.println(i+"\t Google");
i++;
}
}
}
Using Do-While Statements:
class dowhil
{
public static void main(String[] arg)
{
int i=0;
do
{
System.out.println(i+"\t Google");
i++;
}
while(i!=5);
}
}
Use notation:
for While:
C:\>cd\sdk\jdk\bin Press Enter
* C:\>javac whil.java Press Enter
* C:\>;java whil Press Enter
Output:
for do-while:
C:\>cd\sdk\jdk\bin Press Enter
* C:\>javac dowhil.java Press Enter
* C:\>;java dowhil 0 Press Enter
Output:

A Small Discussion On How to store a word inside a variable called array:
Array: Array is a collection of similar elements stored inside a common variable.
Suppose 'a' is an array type variable,
'a' can store either integer type or character type values,
For example: a[]={'d','i','p'};
a[]={1,2,3};
Types of Array:
class arr
{
public static void main(String arg[])
{
int a[]={30,20,12,11,56},i,j,k,n,temp;
for(i=0;i<5;i++)
{
System.out.println("Array data: "+a[i]);
}
}
}
Use notation:
C:\>cd\sdk\jdk\bin Press Enter
* C:\>javac arr.java Press Enter
* C:\>;java arr Press Enter
Output:

A Program demonstrating a Multi-Dimensional Array:
class multi
{
public static void main(String arg[])
{
int a[][]={{1,2,3},{4,5,6},{7,8,9}};
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
System.out.print(a[i][j]);
}
System.out.println();
}
}
}
Use notation:
C:\>cd\sdk\jdk\bin Press Enter
* C:\>javac multi.java Press Enter
* C:\>;java multi Press Enter
Output:

String: String is a set of elements stored inside a common variable.
For example: String can be defined as follows:
String can be Manipulated, There are lots of Predefined Functions in Java use to Manipulate a String,
The Following are the types of String Manipulation Functions:
Examples of the above topic will be seen in the next context.....class week
{
public static void main(String arg[])
{
int a;
a=Integer.parseInt(arg[0]);
switch(a)
{
case 0:
System.out.println("Monday");
break;
case 1:
System.out.println("Tuesday");
break;
case 2:
System.out.println("Wednesday");
break;
case 3:
System.out.println("Thursday");
break;
case 4:
System.out.println("Friday");
break;
case 5:
System.out.println("Satday");
break;
case 6:
System.out.println("Sunday");
break;
default:
System.out.println("Invalid Input, enter Input between 0-6: ");
break;
}
}
}
Use notation:
C:\>cd\sdk\jdk\bin Press Enter
* C:\>javac week.java Press Enter
* C:\>;java week 0 Press Enter
Two Programs Showing Difference Between While and Do-While Statements
Using While Statement:
class whil
{
public static void main(String[] arg)
{
int i=0;
while(i!=5)
{
System.out.println(i+"\t Google");
i++;
}
}
}
Using Do-While Statements:
class dowhil
{
public static void main(String[] arg)
{
int i=0;
do
{
System.out.println(i+"\t Google");
i++;
}
while(i!=5);
}
}
Use notation:
for While:
C:\>cd\sdk\jdk\bin Press Enter
* C:\>javac whil.java Press Enter
* C:\>;java whil Press Enter
Output:
for do-while:
C:\>cd\sdk\jdk\bin Press Enter
* C:\>javac dowhil.java Press Enter
* C:\>;java dowhil 0 Press Enter
Output:
A Small Discussion On How to store a word inside a variable called array:
Array: Array is a collection of similar elements stored inside a common variable.
Suppose 'a' is an array type variable,
'a' can store either integer type or character type values,
For example: a[]={'d','i','p'};
a[]={1,2,3};
Types of Array:
- Single Dimension, for eg: a[]={1,2,3};
- Multi-Dimension for eg a[][]={{1,2,3},{4,5,6},{7,8,9}}
class arr
{
public static void main(String arg[])
{
int a[]={30,20,12,11,56},i,j,k,n,temp;
for(i=0;i<5;i++)
{
System.out.println("Array data: "+a[i]);
}
}
}
Use notation:
C:\>cd\sdk\jdk\bin Press Enter
* C:\>javac arr.java Press Enter
* C:\>;java arr Press Enter
Output:
A Program demonstrating a Multi-Dimensional Array:
class multi
{
public static void main(String arg[])
{
int a[][]={{1,2,3},{4,5,6},{7,8,9}};
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
System.out.print(a[i][j]);
}
System.out.println();
}
}
}
Use notation:
C:\>cd\sdk\jdk\bin Press Enter
* C:\>javac multi.java Press Enter
* C:\>;java multi Press Enter
Output:
String: String is a set of elements stored inside a common variable.
For example: String can be defined as follows:
- byte a[]={65,45,36,78};
String s=new String(a); - char b[]={'d','i','p'};
String s1=new String(b); - String a="dip"; //also known as String literal
String can be Manipulated, There are lots of Predefined Functions in Java use to Manipulate a String,
The Following are the types of String Manipulation Functions:
- Character Type Manipulation:
- getchars(int source start, int source end, char target[], int target start)
- regionmatches(start index, string2, start index, integer number of character)
- String Type Manipulation:
- length()
- concat()
- indexof()
- substring()
- replace()
- trim()
- touppercase()
- tolowercase()
- equals()
- equalsignorecase()
- reverse()
- regionmatches()
- startswith()
- endswith()