Saturday, April 11, 2009

JAVA PROGRAMMS1

class Bistream{
Void static main (String args[]){
Try{
BufferedInputStream in = new new BufferedInputStream (new FileInputStream("test.txt))); //create an object of fileinputstream type
//and construct BufferedInputStream from it.
Int i;
while((i = in.read ())!= -1)
System.out.Print(i);
in.close();
} catch (exception e){};
}
}


--------------------------------------------------


/* Program to create thread by implementing runnable interface
Author : Team -J
Version : 1.0 */
class Thread1{
static public void main(String[] args){
Thread myThreadA = new Thread(new MyThread1(),"threadA");
Thread myThreadB = new Thread(new MyThread1(),"threadB");
//run the two threads
myThreadA.start();
myThreadB.start();

try{
Thread.currentThread().sleep(1000);
}catch(InterruptedException e){}
//Display info about the main thread
System.out.println(Thread.currentThread());
}
}
class MyThread1 implements Runnable{
public void run(){
for(int i= 0;i <10; i++)
System.out.println(Thread.currentThread());
}
}


-------------------------------------


/* Program to create thread by implementing runnable interface
Author : Team -J
Version : 1.0 */
class Thread2{
static public void main(String[] args){
Thread myThreadA = new Thread(new MyThread2(),"threadA");
Thread myThreadB = new Thread(new MyThread2(),"threadB");
//run the two threads
myThreadA.start();
myThreadB.start();

try{
Thread.currentThread().sleep(1000);
}catch(InterruptedException e){}
//Display info about the main thread
System.out.println(Thread.currentThread());
}
}
class MyThread2 extends Thread{
public void run(){
for(int i= 0;i <10; i++)
System.out.println(Thread.currentThread());
}
}


-------------------------------------------------


/* Program to demonstrate producer/consumer problem
Author : Team -J
Version : 1.0 */
class sharedvar{
int i;
sharedvar(){
i=0;
}
int incvar(){
return i++;
}
int getvar(){
return i;
}
}
class MyThread3A extends Thread{
sharedvar v;
MyThread3A(sharedvar v){
this.v = v;
}
public void run(){
for(int i= 0;i <10; i++)
System.out.println("Value of shared variable "+ v.getvar());
}

}
class MyThread3B extends Thread{
sharedvar v;
MyThread3B(sharedvar v){
this.v = v;
}
public void run(){
for(int i= 0;i <10; i++){
System.out.println("value of shared variable after incrimenting "+v.incvar());
}
}
}
class Thread3{
static public void main(String[] args){
sharedvar v = new sharedvar();
Thread myThread3A = (Thread) new MyThread3A (v);
myThread3A.start();
Thread myThread3B = (Thread) new MyThread3B (v);
myThread3B.start();
}
}

--------------------------------


/* Program to demonstrate producer/consumer problem
Author : Team -J
Version : 1.0 */
class sharedvar{
int i;
sharedvar(){
i=0;
}
int incvar(){
return i++;
}
int getvar(){
return i;
}
}
class MyThread3A extends Thread{
sharedvar v;
MyThread3A(sharedvar v){
this.v = v;
Thread t = new Thread (this,"Thread3A");
t.run();
}
public void run(){
for(int i= 0;i <10; i++)
System.out.println("Value of shared variable "+ v.getvar());
}

}
class MyThread3B extends Thread{
sharedvar v;
MyThread3B(sharedvar v){
this.v = v;
Thread t = new Thread (this,"Thread3B");
t.run();
}
public void run(){
for(int i= 0;i <10; i++){
System.out.println("value of shared variable after incrimenting "+v.incvar());
}
}
}
class Thread3{
static public void main(String[] args){
sharedvar v = new sharedvar();
new MyThread3A (v);
new MyThread3B (v);
}
}

------------------------------------------------------------

/* Program to solve producer/consumer problem
Author : Team -J
Version : 1.0 */
class sharedvar{
int i;
boolean isvarset;
sharedvar(){
i=0;
isvarset=false;
}
synchronized int incvar(){
if( isvarset) //if var is set wait till the other thread reads it
try{
wait();
}catch(InterruptedException e){};
i++;
isvarset = true;
notify();
return i;
}
synchronized int getvar(){
if (!isvarset)try{
wait();
}catch(InterruptedException e){};
isvarset=false;
notify(); //notify the other thread which is waiting to incerment the value
return i;
}
}
//consumer
class MyThread4A extends Thread{
sharedvar v;
MyThread4A(sharedvar v){
this.v = v;
}
public void run(){
for(int i= 0;i <10; i++)
System.out.println("Value of shared variable "+ v.getvar());
}

}
//producer
class MyThread4B extends Thread{
sharedvar v;
MyThread4B(sharedvar v){
this.v = v;
}
public void run(){
for(int i= 0;i <10; i++)
System.out.println("value of shared variable after incrementing "+v.incvar());

}
}
class Thread4{
static public void main(String[] args){
sharedvar v = new sharedvar();
Thread myThread4A = (Thread) new MyThread4A (v);
myThread4A.start();
Thread myThread4B = (Thread) new MyThread4B (v);
myThread4B.start();
}
}

------------------------------------------------------------
/*Version : 1.0
Program to compute x pow 1 /1 ! + x pow 2 / 2! + x pow 3/ 3!
using for construct
Author : Team - J
*/
public class for2
{
public static void main(String args[]){
int i,j,no=3;
float sum=1.0f;
int prod,nopowx;
for(i=1 ; i<5;i++){
//find no power i
nopowx=no;
for(j=1;j
nopowx= nopowx * no;
System.out.println(" power = " + nopowx);
//find factorial of i
prod=1;
for(j=1;j<=i;j++){
prod=prod * j;
}
System.out.println(prod);
sum=sum + nopowx/prod;
}
System.out.println(" sum = " + sum);
}

}


---------------------------------------

/*Version : 1
This program displays a pattern
&&&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&&&
using for construct
Author : Team - J
*/
public class for3
{
public static void main(String args[]){
int no=10;
int i=1,j;
for(i=1;i<10;i++)
{
if ( (i %2 ) == 0)
System.out.print(" ");
else
System.out.print("&");

for(j=2;j <10;j++)
System.out.print("&");
if ( (i %2 ) == 0)
System.out.print(" ");
else
System.out.print("&");
System.out.println();
}

}
}


-----------------------------------------------------

/*Version : 1
This program uses break and continue
using for construct
Author : Team - J
*/
public class for4
{
public static void main(String args[]){
int no=10;
int i=1,j;
for(i=1;i<10;i++)
{
if ( (i %2 ) == 0)
continue;
/* break;*/
System.out.println(i);
}

}
}


-------------------------------------------------

/*Version : 1
This program uses break and continue
using for construct
Author : Team - J
*/
public class for5
{
public static void main(String args[]){
int no=10;
int i=1,j;
outer_for: for(j=0;j<10;j++){
for(i=1;i<10;i++)
{
if ( (i %2 ) == 0)
/* continue;*/
break outer_for;
System.out.println(i);
}
}

}
}


---------------------------------------


/*Version : 1
This program prints the following pattern
*********
*******
*****
***
*
using for construct
Author : Team - J
*/
public class for6
{
public static void main(String args[]){
int max=9,lines=5,spaces=0;
int i=1,j,k;
for(i=0;i
// print spaces first
for(k=0;k
System.out.print(" ");
for(j=0;j<(max- spaces*2);j++)
System.out.print("*");
spaces++;
System.out.println();
}

}
}



-----------------------------


/*Version : 1.0
This program prints the following pattern
*
***
*****
*******
*********
using for construct
Author : Team - J
*/
public class for7
{
public static void main(String args[]){
int stars=1,lines=5,spaces=5;
int i=1,j,k;
for(i=0;i
// print spaces first
for(k=0;k
System.out.print(" ");
for(j=0;j<(stars);j++)
System.out.print("*");
spaces--;
stars +=2;
System.out.println();
}

}
}


--------------------------------


/*Version : 1
This program prints the following pattern
*
***
*****
*******
*********
using for construct
Author : Team - J
*/
public class for8
{
public static void main(String args[]){
int stars=1,lines=5;
int i=1,j,k;
for(i=0;i
for(j=0;j<(stars);j++)
System.out.print("*");
stars+=2;
System.out.println();
}

}
}


---------------------------------------


/*Version : 1
This program prints the following pattern
using for construct
Author : Team - J
*/
public class for9
{
public static void main(String args[]){
int stars=1,lines=5;
int i=1,j,k;
for(i=0;;i++){
System.out.println(i);
}

}
}


-----------------------------------------

/*Version : 1.0
Program to show how multiple statements can be included in For init
using for construct
Author : Team - J
*/
public class for10
{
public static void main(String args[]){
int i,j,no=3,f=0,k=10;
float sum=1.0f;
int prod,nopowx;
for(i=1,j=0,no=3 ; i<5;i++,f++,k+=99){
//find no power i
nopowx=no;
for(j=1;j
nopowx= nopowx * no;
System.out.println(" power = " + nopowx);
//find factorial of i
prod=1;
for(j=1;j<=i;j++){
prod=prod * j;
}
System.out.println(prod);
sum=sum + nopowx/prod;
}
System.out.println(" sum = " + sum);
System.out.println(i + " " + j + " " + f + " " + k);
}
}


-------------------------------

/*Version : 1.0
Program to show how to use multiple expression statements in For init
using for construct
Author : Team - J
*/
public class formultiexp
{
public static void main(String args[]){
int i,j,no=3,f=0,k=10;
float sum=1.0f;
int prod,nopowx;
for(i=1,j=0,no=3,System.out.println("in For init") ; i<5;i++,f++,k+=99,System.out.println("in For update"),System.out.println("in For update2")){
System.out.println("in For body");
}

}
}


----------------------------------------------------


/*Version : 1
Program using for construct
1+1/1!+1/2!+1/3!+1/4!
Author : Team - J
*/
public class forone
{
public static void main(String args[]){
int i,j,no;
float sum=1.0f;
int prod;
for(i=1 ; i<5;i++){
//find factorial of i
prod=1;
for(j=1;j<=i;j++){
prod=prod * j;

}
System.out.println(prod);
sum=sum + 1.0F/prod;
}
System.out.println(" sum = " + sum);
}
}


---------------------------

ForStatement:
for ( ForInit opt ; Expression opt ; ForUpdate opt )
Statement | Block of Statements

ForInit:
StatementExpressionList
LocalVariableDeclaration
ForUpdate:
StatementExpressionList
StatementExpressionList:
StatementExpression
StatementExpressionList , StatementExpression

---------------------------------------------



/*Version : 1.0
Program to show how to use labled continue
using for construct
Author : Team - J
*/
public class lablecontinuefor
{
public static void main(String args[]){
int i,j,no=3,f=0,k=10;
float sum=1.0f;
lab1:
System.out.println(" lable one");
//lab1:
//System.out.println(" lable one second time");
int prod,nopowx;

lab1:
//while(true){
//System.out.println(" in while");
lab2:
for(i=1; i<3;i++){

System.out.println(" value of i = " +i);
lab3:
for(j=1;j<=4;j++){
System.out.println(" value of j = " + j);
if( j ==1)
continue lab3;
System.out.println(" After break lab3");
if( j ==2)
continue lab3;
System.out.println(" After break lab3 ..");
if( j ==3)
continue lab1;
System.out.println(" After break lab1");
}
}
//}

}
}


--------------------------------------------


/*Version : 1.0
Program to show how to use labled break
using for construct
Author : Team - J
*/
public class lablefor
{
public static void main(String args[]){
int i,j,no=3,f=0,k=10;
float sum=1.0f;
lab1:
System.out.println(" lable one");
//lab1:
//System.out.println(" lable one second time");
int prod,nopowx;

lab1:
while(true){
System.out.println(" in while");
lab2:
for(i=1; i<3;i++){

System.out.println(" value of i = " +i);
lab3:
for(j=1;j<=4;j++){
System.out.println(" value of j = " + j);
if( j ==1)
break lab3;
System.out.println(" After break lab3");
if( j ==2)
break lab3;
System.out.println(" After break lab2");
if( j ==3)
break lab1;
System.out.println(" After break lab1");
}
}
}

}
}

---------------------------------------------

JAVA3
/*Version : 1.0
Program to compute x pow 1 /1 ! + x pow 2 / 2! + x pow 3/ 3!
using for construct
Author : Team - J
*/
public class for2
{
public static void main(String args[]){
int i,j,no=3;
float sum=1.0f;
int prod,nopowx;
for(i=1 ; i<5;i++){
//find no power i
nopowx=no;
for(j=1;j
nopowx= nopowx * no;
System.out.println(" power = " + nopowx);
//find factorial of i
prod=1;
for(j=1;j<=i;j++){
prod=prod * j;
}
System.out.println(prod);
sum=sum + nopowx/prod;
}
System.out.println(" sum = " + sum);
}

}


---------------------------------------

/*Version : 1
This program displays a pattern
&&&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&&&
using for construct
Author : Team - J
*/
public class for3
{
public static void main(String args[]){
int no=10;
int i=1,j;
for(i=1;i<10;i++)
{
if ( (i %2 ) == 0)
System.out.print(" ");
else
System.out.print("&");

for(j=2;j <10;j++)
System.out.print("&");
if ( (i %2 ) == 0)
System.out.print(" ");
else
System.out.print("&");
System.out.println();
}

}
}


-----------------------------------------------------

/*Version : 1
This program uses break and continue
using for construct
Author : Team - J
*/
public class for4
{
public static void main(String args[]){
int no=10;
int i=1,j;
for(i=1;i<10;i++)
{
if ( (i %2 ) == 0)
continue;
/* break;*/
System.out.println(i);
}

}
}


-------------------------------------------------

/*Version : 1
This program uses break and continue
using for construct
Author : Team - J
*/
public class for5
{
public static void main(String args[]){
int no=10;
int i=1,j;
outer_for: for(j=0;j<10;j++){
for(i=1;i<10;i++)
{
if ( (i %2 ) == 0)
/* continue;*/
break outer_for;
System.out.println(i);
}
}

}
}


---------------------------------------


/*Version : 1
This program prints the following pattern
*********
*******
*****
***
*
using for construct
Author : Team - J
*/
public class for6
{
public static void main(String args[]){
int max=9,lines=5,spaces=0;
int i=1,j,k;
for(i=0;i
// print spaces first
for(k=0;k
System.out.print(" ");
for(j=0;j<(max- spaces*2);j++)
System.out.print("*");
spaces++;
System.out.println();
}

}
}



-----------------------------


/*Version : 1.0
This program prints the following pattern
*
***
*****
*******
*********
using for construct
Author : Team - J
*/
public class for7
{
public static void main(String args[]){
int stars=1,lines=5,spaces=5;
int i=1,j,k;
for(i=0;i
// print spaces first
for(k=0;k
System.out.print(" ");
for(j=0;j<(stars);j++)
System.out.print("*");
spaces--;
stars +=2;
System.out.println();
}

}
}


--------------------------------


/*Version : 1
This program prints the following pattern
*
***
*****
*******
*********
using for construct
Author : Team - J
*/
public class for8
{
public static void main(String args[]){
int stars=1,lines=5;
int i=1,j,k;
for(i=0;i
for(j=0;j<(stars);j++)
System.out.print("*");
stars+=2;
System.out.println();
}

}
}


---------------------------------------


/*Version : 1
This program prints the following pattern
using for construct
Author : Team - J
*/
public class for9
{
public static void main(String args[]){
int stars=1,lines=5;
int i=1,j,k;
for(i=0;;i++){
System.out.println(i);
}

}
}


-----------------------------------------

/*Version : 1.0
Program to show how multiple statements can be included in For init
using for construct
Author : Team - J
*/
public class for10
{
public static void main(String args[]){
int i,j,no=3,f=0,k=10;
float sum=1.0f;
int prod,nopowx;
for(i=1,j=0,no=3 ; i<5;i++,f++,k+=99){
//find no power i
nopowx=no;
for(j=1;j
nopowx= nopowx * no;
System.out.println(" power = " + nopowx);
//find factorial of i
prod=1;
for(j=1;j<=i;j++){
prod=prod * j;
}
System.out.println(prod);
sum=sum + nopowx/prod;
}
System.out.println(" sum = " + sum);
System.out.println(i + " " + j + " " + f + " " + k);
}
}


-------------------------------

/*Version : 1.0
Program to show how to use multiple expression statements in For init
using for construct
Author : Team - J
*/
public class formultiexp
{
public static void main(String args[]){
int i,j,no=3,f=0,k=10;
float sum=1.0f;
int prod,nopowx;
for(i=1,j=0,no=3,System.out.println("in For init") ; i<5;i++,f++,k+=99,System.out.println("in For update"),System.out.println("in For update2")){
System.out.println("in For body");
}

}
}


----------------------------------------------------


/*Version : 1
Program using for construct
1+1/1!+1/2!+1/3!+1/4!
Author : Team - J
*/
public class forone
{
public static void main(String args[]){
int i,j,no;
float sum=1.0f;
int prod;
for(i=1 ; i<5;i++){
//find factorial of i
prod=1;
for(j=1;j<=i;j++){
prod=prod * j;

}
System.out.println(prod);
sum=sum + 1.0F/prod;
}
System.out.println(" sum = " + sum);
}
}


---------------------------

ForStatement:
for ( ForInit opt ; Expression opt ; ForUpdate opt )
Statement | Block of Statements

ForInit:
StatementExpressionList
LocalVariableDeclaration
ForUpdate:
StatementExpressionList
StatementExpressionList:
StatementExpression
StatementExpressionList , StatementExpression

---------------------------------------------



/*Version : 1.0
Program to show how to use labled continue
using for construct
Author : Team - J
*/
public class lablecontinuefor
{
public static void main(String args[]){
int i,j,no=3,f=0,k=10;
float sum=1.0f;
lab1:
System.out.println(" lable one");
//lab1:
//System.out.println(" lable one second time");
int prod,nopowx;

lab1:
//while(true){
//System.out.println(" in while");
lab2:
for(i=1; i<3;i++){

System.out.println(" value of i = " +i);
lab3:
for(j=1;j<=4;j++){
System.out.println(" value of j = " + j);
if( j ==1)
continue lab3;
System.out.println(" After break lab3");
if( j ==2)
continue lab3;
System.out.println(" After break lab3 ..");
if( j ==3)
continue lab1;
System.out.println(" After break lab1");
}
}
//}

}
}


--------------------------------------------


/*Version : 1.0
Program to show how to use labled break
using for construct
Author : Team - J
*/
public class lablefor
{
public static void main(String args[]){
int i,j,no=3,f=0,k=10;
float sum=1.0f;
lab1:
System.out.println(" lable one");
//lab1:
//System.out.println(" lable one second time");
int prod,nopowx;

lab1:
while(true){
System.out.println(" in while");
lab2:
for(i=1; i<3;i++){

System.out.println(" value of i = " +i);
lab3:
for(j=1;j<=4;j++){
System.out.println(" value of j = " + j);
if( j ==1)
break lab3;
System.out.println(" After break lab3");
if( j ==2)
break lab3;
System.out.println(" After break lab2");
if( j ==3)
break lab1;
System.out.println(" After break lab1");
}
}
}

}
}

---------------------------------------------

JAVA3
/*Version : 1.0
Program to compute x pow 1 /1 ! + x pow 2 / 2! + x pow 3/ 3!
using for construct
Author : Team - J
*/
public class for2
{
public static void main(String args[]){
int i,j,no=3;
float sum=1.0f;
int prod,nopowx;
for(i=1 ; i<5;i++){
//find no power i
nopowx=no;
for(j=1;j
nopowx= nopowx * no;
System.out.println(" power = " + nopowx);
//find factorial of i
prod=1;
for(j=1;j<=i;j++){
prod=prod * j;
}
System.out.println(prod);
sum=sum + nopowx/prod;
}
System.out.println(" sum = " + sum);
}

}


---------------------------------------

/*Version : 1
This program displays a pattern
&&&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&&&
using for construct
Author : Team - J
*/
public class for3
{
public static void main(String args[]){
int no=10;
int i=1,j;
for(i=1;i<10;i++)
{
if ( (i %2 ) == 0)
System.out.print(" ");
else
System.out.print("&");

for(j=2;j <10;j++)
System.out.print("&");
if ( (i %2 ) == 0)
System.out.print(" ");
else
System.out.print("&");
System.out.println();
}

}
}


-----------------------------------------------------

/*Version : 1
This program uses break and continue
using for construct
Author : Team - J
*/
public class for4
{
public static void main(String args[]){
int no=10;
int i=1,j;
for(i=1;i<10;i++)
{
if ( (i %2 ) == 0)
continue;
/* break;*/
System.out.println(i);
}

}
}


-------------------------------------------------

/*Version : 1
This program uses break and continue
using for construct
Author : Team - J
*/
public class for5
{
public static void main(String args[]){
int no=10;
int i=1,j;
outer_for: for(j=0;j<10;j++){
for(i=1;i<10;i++)
{
if ( (i %2 ) == 0)
/* continue;*/
break outer_for;
System.out.println(i);
}
}

}
}


---------------------------------------


/*Version : 1
This program prints the following pattern
*********
*******
*****
***
*
using for construct
Author : Team - J
*/
public class for6
{
public static void main(String args[]){
int max=9,lines=5,spaces=0;
int i=1,j,k;
for(i=0;i
// print spaces first
for(k=0;k
System.out.print(" ");
for(j=0;j<(max- spaces*2);j++)
System.out.print("*");
spaces++;
System.out.println();
}

}
}



-----------------------------


/*Version : 1.0
This program prints the following pattern
*
***
*****
*******
*********
using for construct
Author : Team - J
*/
public class for7
{
public static void main(String args[]){
int stars=1,lines=5,spaces=5;
int i=1,j,k;
for(i=0;i
// print spaces first
for(k=0;k
System.out.print(" ");
for(j=0;j<(stars);j++)
System.out.print("*");
spaces--;
stars +=2;
System.out.println();
}

}
}


--------------------------------


/*Version : 1
This program prints the following pattern
*
***
*****
*******
*********
using for construct
Author : Team - J
*/
public class for8
{
public static void main(String args[]){
int stars=1,lines=5;
int i=1,j,k;
for(i=0;i
for(j=0;j<(stars);j++)
System.out.print("*");
stars+=2;
System.out.println();
}

}
}


---------------------------------------


/*Version : 1
This program prints the following pattern
using for construct
Author : Team - J
*/
public class for9
{
public static void main(String args[]){
int stars=1,lines=5;
int i=1,j,k;
for(i=0;;i++){
System.out.println(i);
}

}
}


-----------------------------------------

/*Version : 1.0
Program to show how multiple statements can be included in For init
using for construct
Author : Team - J
*/
public class for10
{
public static void main(String args[]){
int i,j,no=3,f=0,k=10;
float sum=1.0f;
int prod,nopowx;
for(i=1,j=0,no=3 ; i<5;i++,f++,k+=99){
//find no power i
nopowx=no;
for(j=1;j
nopowx= nopowx * no;
System.out.println(" power = " + nopowx);
//find factorial of i
prod=1;
for(j=1;j<=i;j++){
prod=prod * j;
}
System.out.println(prod);
sum=sum + nopowx/prod;
}
System.out.println(" sum = " + sum);
System.out.println(i + " " + j + " " + f + " " + k);
}
}


-------------------------------

/*Version : 1.0
Program to show how to use multiple expression statements in For init
using for construct
Author : Team - J
*/
public class formultiexp
{
public static void main(String args[]){
int i,j,no=3,f=0,k=10;
float sum=1.0f;
int prod,nopowx;
for(i=1,j=0,no=3,System.out.println("in For init") ; i<5;i++,f++,k+=99,System.out.println("in For update"),System.out.println("in For update2")){
System.out.println("in For body");
}

}
}


----------------------------------------------------


/*Version : 1
Program using for construct
1+1/1!+1/2!+1/3!+1/4!
Author : Team - J
*/
public class forone
{
public static void main(String args[]){
int i,j,no;
float sum=1.0f;
int prod;
for(i=1 ; i<5;i++){
//find factorial of i
prod=1;
for(j=1;j<=i;j++){
prod=prod * j;

}
System.out.println(prod);
sum=sum + 1.0F/prod;
}
System.out.println(" sum = " + sum);
}
}


---------------------------

ForStatement:
for ( ForInit opt ; Expression opt ; ForUpdate opt )
Statement | Block of Statements

ForInit:
StatementExpressionList
LocalVariableDeclaration
ForUpdate:
StatementExpressionList
StatementExpressionList:
StatementExpression
StatementExpressionList , StatementExpression

---------------------------------------------



/*Version : 1.0
Program to show how to use labled continue
using for construct
Author : Team - J
*/
public class lablecontinuefor
{
public static void main(String args[]){
int i,j,no=3,f=0,k=10;
float sum=1.0f;
lab1:
System.out.println(" lable one");
//lab1:
//System.out.println(" lable one second time");
int prod,nopowx;

lab1:
//while(true){
//System.out.println(" in while");
lab2:
for(i=1; i<3;i++){

System.out.println(" value of i = " +i);
lab3:
for(j=1;j<=4;j++){
System.out.println(" value of j = " + j);
if( j ==1)
continue lab3;
System.out.println(" After break lab3");
if( j ==2)
continue lab3;
System.out.println(" After break lab3 ..");
if( j ==3)
continue lab1;
System.out.println(" After break lab1");
}
}
//}

}
}


--------------------------------------------


/*Version : 1.0
Program to show how to use labled break
using for construct
Author : Team - J
*/
public class lablefor
{
public static void main(String args[]){
int i,j,no=3,f=0,k=10;
float sum=1.0f;
lab1:
System.out.println(" lable one");
//lab1:
//System.out.println(" lable one second time");
int prod,nopowx;

lab1:
while(true){
System.out.println(" in while");
lab2:
for(i=1; i<3;i++){

System.out.println(" value of i = " +i);
lab3:
for(j=1;j<=4;j++){
System.out.println(" value of j = " + j);
if( j ==1)
break lab3;
System.out.println(" After break lab3");
if( j ==2)
break lab3;
System.out.println(" After break lab2");
if( j ==3)
break lab1;
System.out.println(" After break lab1");
}
}
}

}
}


Monday, February 9, 2009

NanoSyntax Based Computers

REVOLUTIONARY SOFTWARE


Introduction

Computers cannot understand human languages, unless there is software to translate it to something the CPU can understand. So there should be languages specifically designed for computers. The software takes the input, translates it, and sends it to the desired location. Some programming languages are based on English; such as BASIC, which uses commands like GOTO, PRINT, and INPUT.

What lead me to think of NanoSyntax based computers?

As a software developer every one can have their own ambition to develop the best software. Developing impeccable software is not easy. The study of ideal situations may lead to change in the society i.e. Development in the society. Due to the same reason, I am planning to share my knowledge here.


Problem Statement

It's been called the 'holy grail' of computer technology - software that will enable people to speak to computers in 'natural language', the same way they speak to each other. Computer scientists around the world have been working towards this elusive goal for more than a decade, but without real success.
Will we make it?
Yes, Jerusalem-based start-up Linguistic Agents says it has created an application that will allow computers to understand human language - and will revolutionize the world of computers in the process. The founder and CEO of this company developed “Advanced Language machine”-or ALM-, who studied linguistics at UCLA and computer science at Herbew University, putting years of attention towards creating an engine that could accurately decode human language.
The ALM diagrams sentences using a recent advance in theoretical linguistics known as ‘NanoSyntax’. NanoSyntax, developed by linguists at the Massachusetts Institute of Technology in 2004 breaks language down into its component parts, going beyond words to parse the meaning of sentences. It was the introduction of NanoSyntax, with its greater ability to decode ambiguity, has made their innovation possible.

Computational linguistics works to understand bits of meaning from individual words and what you can extract from them, rather than trying to decode meaning in a phrase or sentence. In contrast, "NanoSyntax is saying we can understand sentences."

Above picture explains how the NanoSyntactic based computer works.
To put it another way, NanoSyntax describes how the brain takes the information embedded in language and understands it. This, according to Taber, is far from simple.

"The brain has an ability to understand language without knowing the words," he explains. "If say a sentence with a word you may have never heard, through the context, you'd be able to understand 70% of what I'm saying without that word, or even understand what that word means, just by the context. That's what makes us very special."

Using the core technology of NanoSyntax, Linguistic Agents' computer scientists and programmers set out to create a technology that would mirror this process - only backwards. Instead of taking meaning from the brain, where it's created, Linguistic Agents needed to figure out a way to take sentences and convert the information in them to a format, a linguistic tree, that would enable a computer to understand their meanings. It has taken six years of development, but now Margaliot and his staff of eight have alpha and beta versions of the technology.

In a recent demo, Linguistic Agents' staff showed ISRAEL21c what a search in their new yellow pages directory would look like. Given the search phrase "I'm looking for a hotel," the directory came back immediately with the question, "where?"
"That's way beyond a search engine," claims Taber, "because Google, even if it would somewhat be able to understand (which it won't), would just look for the words 'look for' and 'hotel'."

Instead, the Intelligent Command Engine understands the question, and that it needs more information to provide the answer. And the engine retains the information it has already received, so that when we responded “Hyderabad” to its query, it was enough for the program to respond with a list of hotels in the city.

The possible applications seem nearly limitless. By being able to ask a computer, in natural language, what a person is looking for, search engines could be improved, automated help lines could be more efficient, information could be more easily accessible on websites - the list goes on and on.

And, as the world quickly shifts to handheld devices with multiple functions, Linguistic Agents' Intelligent Command Engine will become even more valuable by helping make these intelligent devices more user-friendly.

Currently, the software is available only for written, or 'typed in' language, but Linguistic Agents is hoping to have voice-enabled technology ready by few years.

One of the main advantages of the software is that it operates on minimal system resources and is therefore easily integrated into existing applications. And, while the beta version exists in both English and Hebrew, because of the sophistication of the NanoSyntax model, it is easily adaptable to most languages with only small adjustments. Linguistic Agents' close-knit team has high hopes for its technology.

Results
NanoSyntax based computers; devices give the great change in the lifecycle of human being. The basic advantages with this are:
This software makes computers more user-friendly.
Robots, which work like human, can be developed.
Work load on the humans can be decreased.
The applications of these computers may be more. It is not an exaggeration that we are going to get an ‘Artificial Man’.
Conclusion
Even though we had computers train us how to talk to them. We are unable to talk the way we do with our friends. If we do that, it's a revolution, an entire way anything computes, and everything computes.
I think bringing computers to a new generation is so big... it's hard to say how big it will be…
WISH TO HAVE A POSSITIVE RESULT


By
Mallikarjun Gunda,
(mallikarjungunda@yahoo.com)

Friday, November 7, 2008

When computer understand human language(talks)?

Answer for this question is little bit difficult. But according to my view, When we have a software which understand the English and process the English and gives the good result. In such situation using the processors we can convert the human talks into respective English language (Alphabets & words). By passing that information to the computer it will work with human talks and there is no need of typing on the keyboard.
By seeing this I am getting lough but If we accept this we may achieve the good thing. To achieve this we have to develop a software which understand English but not the programming languages.
I thank you very much for spending valuable time and I wish all suggestions from your side.
You can send your suggestions to mallikarjungunda@gmail.com (or) mallikarjungunda@yahoo.com

Thank you,
yours,
Mallik

Saturday, November 1, 2008

My phot

హాయ్ ఇది నా ఫోటో