The code should be saved
in a text file with a .java extension. //
Classname must be same as filename.
public class test { // Variables
private static String myText = "Hello,
World"; private static String msg;
private static int myInt
= 10;
// Main - Where the Action
Starts public static void main(String args[])
{
// Print "Hello, World"
to the screen. System.out.println("Hello,
World\n");
// Multiplication for each
value for (int i = 0; i <10; i++) {
// Print Calculations to
Screen System.out.println(calc(i)); } }
// Handle the calculations
public static String calc(int timesBy) {
// Put calculation into
string msg = myInt + " x " + timesBy
+ "= " + (myInt * timesBy) + "\n";
// Return Calculation return
msg; } } span>
(Information gathered from Codepedia: The developers encyclopedia - http://www.codepedia.com/1/BegiinnersGuideToJava)
|