Monday, 1 August 2011

The if decision structure

The if statement evaluates a condition and if the result is true then it runs the line of code that follows it. Here is an example of how to test if the value of a variable called I is equal to 5 :public class Decisions{               public static void main( String [ ] args )                {                int i = 5 ;              ...

How to use Command-Line Arguments

Using Command-Line ArgumentsHelps us to pass information into a program when it is runclass CommandLine {public static void main (String args [ ] ) {for (int i= 0; I < args.length ; i ++ )System.out.println(“ args [ “ + i + “ ] ; “ + args [ i ]) ;}} To execute a program, we write from the command prompt: java CommandLine this is a test 100...

Simple program to arrange the citynames in ascending order

Simple program to arrange the citynames in ascending order class stasc{                    public static void main (String args [ ])                     {                                       ...

arrange the numbers in descending order

class comm.{                    public static void main (String args [] )                    {                    int I,j,k ;                    k= args.length;                   ...

Twitter Delicious Facebook Digg Stumbleupon Favorites More