Sunday, November 20, 2011

for each

Guess the output: public class ForEachDemo { public static void main(String args[]){ int a[]={1,8,1,1,1,1,1,1,1,1}; for(int i:a)//for each is for arrays display System.out.println(a[i]); } } Output: 8 1 8 8 8 8 8 8 8 8




Guess the output: public class ForEachDemo { public static void main(String args[]){ int a[]={1,8,1,1,1,1,1,1,1,1}; for(int i:a)//for each is for arrays display System.out.println(i); } }
output:
1 8 1 1 1 1 1 1 1 1

Sunday, November 13, 2011

processing streams

perform some sort of operation such as buffering or encoding as they reaad and write.

Data sink stream

they are used to read from or write to specialized data sink such as files pipes strings.

java.io package

contain all classes that are required to handle input and output

character stream

reader and writer stream are character stream

byte stream

Input and output stream are byte stream.eg:images ,sounds.
2 types:
1.ObjectInputStream
2.ObjectOutputStram

System.err

System is a class in java.lang package and contain a predefined stream variable err.
refers to standard error stream which is also console

it is object of type PrintStream.
it is a byte stream.

ec2-user@ec2 Permission denied