See more articles about "java "

Tutorial Addendum On Java - Beheading Of Java Programs



 31 December 18:00   

    



    



    

Execution Access Point

    



    

As mentioned in the antecedent section, a Java appliance program haveto accept

    

a starting chic with a appropriate adjustment alarm main() as the beheading access point.

    

The main() adjustment haveto be authentic as follows:

    

 

    

accessible changeless abandoned main(String a) {

    

// account block

    

}

    



    



    

Note that the main() adjustment is a chic method, authentic as "static". So if it

    

is alleged by the JVM, no instance of the starting chic will be created.

    



    

The constant of the main() adjustment is an arrangement of "String", which contains the

    

additional arguments afterwards the chic name altercation in the "java" command line.

    

Let s use the afterward Java program to allegorize how those arguments are

    

passed into the main() method:

    

 

    

/**

    

* CommandLine.java

    

* Absorb (c) 2002 by Dr. Yang

    

*/

    

class CommandLine {

    

accessible changeless abandoned main(String a) {

    

System.out.println("Number of arguments = "+a.length);

    

for (int i=0; i<a.length; i++) {

    

System.out.println(" a = "+a);

    

}

    

}

    

}

    



    



    

After accumulation the class, assassinate it with the afterward command line:

    

 

    

c:j2sdk1.4.1_01injava -cp . CommandLine aliment milk assistant apple

    



    



    

Output:

    

 

    

Number of arguments = 4

    

a = bread

    

a = milk

    

a = banana

    

a = apple

    



    



    

4 arguments are defined in the command band afterwards the chic name.

    

The JVM put them in an arrangement of 4 elements and canyon the arrangement as

    

a constant to the main() method.

    



    

Execute it afresh with a hardly altered command line:

    

 

    

c:j2sdk1.4.1_01injava -cp . CommandLine "bread milk" "banana apple"

    

Number of arguments = 2

    

a = aliment milk

    

a = assistant apple

    



    



    

This time, bifold quotes are acclimated to create two amplitude belted words as

    

a individual argument.

    



    



 


 class, method, arguments, command, execution, banana, commandline, bread, array, static, string, , main method, command line, bread milk, bread milk banana, commandline bread milk, void main string, static void main, public static void,

Share Tutorial Addendum On Java - Beheading Of Java Programs:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Tutorial Addendum On Java - Beheading Of Java Programs
Execution ConsoleWhen the JVM is active a Java appliance program, it needs a animate windowto provides 3 predefined ascribe and achievement streams to the Java program: to:br

Tutorial Addendum On Java - Synchronization
Why SynchronizationThe better problem of acceptance assorted accoutrement administration the aforementioned data setis that one operation in one cilia could bang with addition operation

Tutorial Addendum On Java - Synchronization
Synchronization Abutment in JavaInstead of let the programmers to architecture their own locks, administer the synchronization blocks, and administer the synchronization rules, Java

Tutorial Addendum On Java - Synchronization
Synchronization Sample ProgramNow, let s address a Java program to see how the synchronization techniquecan break the coffer problem. Two classes are advised to simulate a bankp

Tutorial Addendum On Java - Synchronization
clandestine changeless abandoned printResult() { System.out.print("Account"); for (int i=0; i<t_maxi; i++) System.out.print(", ATM "+i); System.out.print(", Transaction Sum, Balance"); for (int j=0; j<

Tutorial Addendum On Java - Synchronization
Output: No synchronization:Account, ATM 0, ATM 1, ATM 2, ATM 3, ATM 4, Transaction Sum, Balance0, 506.81, 227.06, 286.89, 885.14, 330.11, 465.73, 1051.871, 63.98, 27.74, 413.05, 276.93, 86.81,

Tutorial Addendum On Java - Accoutrement
Output: Hello world! From the capital program.Hello world! From a thread.Note that:The program behaves the aforementioned way as the antecedent p

Tutorial Addendum On Java - Accoutrement
Output Priority: (min, norm, max) = (1, 5, 10)Threads: 0 1 2 3 4 Time Steps: 1527 2229 161931 31864 29386 17416 Steps: 3193 3881 175188 44342 41757 20301 Steps: 6499 5536 204244 74234

Tutorial Addendum On Java - Accoutrement
The afterward program shows that how assorted accoutrement can plan calm to account how some weekdays in anniversary year for 2000 years starting from year 2000. In this program, an array, y_days, is declared as static,s

Tutorial Addendum On Java - Accoutrement
Output of 5 threads: Thread: 0 1 2 3 4 Year: 0 0 0 0 0 Year: 2039 2040 2043 2042 2044 Year: 2067 2040 2048 2042 2044 Year: 2124 2142 2048 2159 2044 Year: 2318 2180 2230 2300 2