RSS

Search Engine

Tuesday, June 8, 2010

Example

The following assumes you know know to develop simple standard Java programs. If you don't know this please see Eclipse Java IDE .

Create a Java project "de.vogella.debug.first" with the package "de.vogella.debug.first" and the following classes.

   
package de.vogella.debug.first;

public class Counter {
private int result=0;
public int getResult() {
return result;
}

public void count() {
for (int i = 0; i < 100; i++) {
result += i +1;
}
}
}

   
package de.vogella.debug.first;

public class Main {

/**
* @param args
*/
public static void main(String[] args) {
Counter counter = new Counter();
counter.count();
System.out.println("We have counted " + counter.getResult());
}

}

0 comments:

Post a Comment