There are four types of streams: InputStream, OutputStream, Reader, and Writer. | |||||||||||||||||
1. Reader. A stream to read characters. 2. Writer. A stream to write characters. 3. InputStream. A stream to read binary data. 4. OutputStream. A stream to write binary data.
|
Tuesday, August 3, 2010
File Streams
Labels:
File and Streams,
File Stream,
inputStream,
OutputStream,
printwiter,
Stream
while statement program
Problem: Create program that ask the user to input "How many hello world you want to print" and the output show number and hello world.
import java.util.Scanner;
public class helloworld
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
int num;
int start=1;
System.out.print("How hello world you want to display");
num=input.nextInt();
while(start<= num)
{
System.out.println(start + ".Hello");
start++;
}
}
}
import java.util.Scanner;
public class helloworld
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
int num;
int start=1;
System.out.print("How hello world you want to display");
num=input.nextInt();
while(start<= num)
{
System.out.println(start + ".Hello");
start++;
}
}
}
Subscribe to:
Posts (Atom)