Tuesday, 9 April 2013

Write a java program which accepts a word from command line and print each character of word on one line.



class Ass1
{
                        public static void main(String args[])
                        {
int len=args[0].length();
for(int i=0;i<len;i++)
                                    {
                                                System.out.println(args[0].charAt(i));
                                    }
}
}
Output:
E:\test>javac ass1.java
E:\test>java Ass1
E:\test>java Ass1 java
j
a
v
a

No comments:

Post a Comment