Today, I gave a lecture in Java 2nd. In the first half, I felt that those data types have been learned in C ++, So I first slipped away ~ When it came out, we saw heavy rain and the sun running at the same time ^_^.
When I came back and finished my homework, I had to go out of the border for half a day, but I didn't think it was very careful. It seems that you should never be careless when using programming ~
/*
Returns the square of the first 10 natural numbers.
Shawn
Citypw @ Copyright
*/
Class Square
{
Static int I, V;
Square ()
{
System. Out. println ("Welcome! ");
Show ();
}
Void show ()
{
For (I = 1; I <= 10; I ++)
{
System. Out. println (I * I); // system. Out. println is like the cout output stream in C ++.
}
}
Public static void main (string [] ARGs) // You must declare it as public static because only one of main is allowed.
{
Square S = New Square ();
}
}
/*
Sorted
Shawn
Citypw @ Copyright
*/
Class Test
{
Static int I, j, temp;
Test () {system. Out. println ("start sorting ");}
Void bubblesort (INT [])
{
// Use a bubble
For (I = 0; I <A. Length/3; I ++)
{
For (j = 0; j <A. Length-1; j ++)
{
If (A [J]> A [J + 1])
{
Temp = A [J];
A [J] = A [J + 1];
A [J + 1] = temp;
}
}
}
}
Public static void main (string [] ARGs)
{
Int [] arrayofints = {3,589, 622,127 };
Test T = new test ();
T. bubblesort (arrayofints );
For (INT I = 0; I <arrayofints. length; I ++) // print the result
System. Out. Print ("" + arrayofints [I]);
}
}