BACK TO HOME

1. Select all the codes inside box below ( Welcome to Compil...till ...return message; }} ) and delete it
2. copy + paste the codes given below or your program
3. click >> compile & execute button
Example 1:
public class Ijhss{
public static void main(String[] args){
System.out.print("ijhss");}}
Examples 2:
public class Pattern1 {//ijhss tangasseri kollam
public static void main(String args[]) {
int i,j,c,n;
n=Integer.parseInt(args[0]);//reading Command Line Arguments
System.out.println("value of n is "+n);
for(i=1;i<=n;i++)
{//emmnlT
for(j=n,c=0;j>0;j--)
if(i<j) System.out.print(" ");
else System.out.print(++c);
for(j=1;j<=n;j++)
if(i>j) System.out.print(--c);
System.out.println();
}
for(i=2;i<=n;i++)
{
for(j=1,c=0;j<=n;j++)
if(i<=j) System.out.print(++c);
else System.out.print(" ");
for(j=n;j>0;j--)
if(i<j) System.out.print(--c);
System.out.println();
}
}}
Screenshot execution of Example 2.command line args
Examples 3:

public class Selection{
public static void main(String args[]){
int ar[],i,j,n,t,p;
n=Integer.parseInt(args[0]);
ar=new int[n];
System.out.println(n+" Numbers to sort");
for(i=0;i<n;i++){
ar[i]=Integer.parseInt(args[i+1]);
System.out.println("Value at ["+(i)+"]= "+ar[i]);}
//SELECTION sorting in ascending order
for (i=0;i<n-1;i++) {
for (j=i+1,p=i;j<n;j++)
if (ar[p]>ar[j]) p=j;
t=ar[i];
ar[i]=ar[p];
ar[p]=t; }
System.out.println("Sorted array");
for (i=0;i<n;i++)
System.out.println("Value at ["+(i)+"]= "+ar[i]); }}
Screenshot execution of Example 3.command line args
Examples 4:

public class TwinPrime{
public static void main(String args[]){
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
System.out.println("To check if "+a+" and "+b+" are twin prime numbers");
if(Math.abs(a-b)==2 && isPrime(a) && isPrime(b))
System.out.println(a+" and "+b+" are twin prime numbers");
else System.out.println(a+" and "+b+" are not twin prime numbers");
}// end of main()
public static boolean isPrime(int n){
for(int i=2;i<=n/2;i++)
if(n%i==0)
return false;
return true;
}// end of isPrime()
}// end of class
Screenshot execution of Example 4.command line args

BACK TO HOME