Sunday, November 13, 2011

System.in

System is a class in java.lang package and has a predefined stream variable in.
refers to standard input that is keyboard.
it is an object of type input stream.
it is a byte stream

System.out

System is the class name and out is a predefined stream variable.
refers to standard output stream which is console
it is object of type PrintStream.
it is a byte stream.

stream

java provide input and output through stream.
Streams are ordered sequence of data that have a source or destination. two categories
1.character stream
2.byte stream

character stream

convenient means of handling input and output data.

byte stream

is used for reading and writing of binary data.

Sunday, November 6, 2011

java program to add 2 numbers

//add this program to your package class addnum { public static void main(String [] args) { int number1=Integer.parseInt(args[0]); int number2=Integer.parseInt(args[0]); System.out.println(number1+number2); } } /* run the program and enter 2 integer values like, 4 5 output: 9 */

java program to add 2 strings

//include this program in your package class calc { public static void main(String args[]) { System.out.println(args[0]+args[1]); } } /*run the program and enter 2 strings like,abc def output:abcdef */

ec2-user@ec2 Permission denied