In the morning again to review the basics of Java, including write a Hello World, learn the double-precision floating point data control bit output, and write a leap year judgment, finally learned the loop, wrote 1-100 cumulative sum, for a result, for a variety of writing methods.
For the output hello with System.out.println, it's OK,
There are three ways to control the output of double-progress floating-point data,
1, in string format
System.out.println (String.Format ("%.2f", a));
2, with printf
System.out.printf ("%.9f", a);
3, with DecimalFormat
DecimalFormat format = new DecimalFormat ("#.0000");
System.out.println (Format.format (a));
Leap year words, the general idea, is divisible by 4 at the same time is divisible by 100, divisible by 400.
&& symbol Yes or, | | IS and
The last is the cycle, there are three ways of circulation, while,do......while,for, for 1-100 accumulation,
1, with while
int a=0,i=1;
while (i<=100)
{
A=a+i;
i++;
}
System.out.println (a);
2,do......while
int a=0,i=1;
Do
{
A=a+i;
i++;
}
while (i<=100);
System.out.println (a);
3,for
int a=0,i;
for (i=1;i<=100;i++)
{
A=a+i;
}
System.out.println (a)
All of this was done this morning.
First, the Java Foundation