3. Write a class to demonstrate defining a variable of type int, assigning it a value, and then printing it on the console
public class two{
public static void main(String args[]){
int a = 123;
System.out.println(a);
}
}
5. Output the following form
public class four {
public static void main(String[] args){
char [][] a =new char[5][5];
int i, j;
for(i=0;ifor(j=0;jif(j>=i)
a[i][j]='*';
else
a[i][j]=' ';
}
for(i=0;ifor(j=0;jSystem.out.print(a[i][j]);
System.out.println();
}
}
}
2. Write a class to test and demonstrate the meaning of the and - operator.
public class first{
public static void main(String args[]){
int a = 5;
System.out.println("a : " (a ));
System.out.println("a-- : " (a--));
System.out.println(" a : " ( a));
System.out.println("--a : " (--a));
}
}
4. Program to compare the sizes of 23 and 32, and output the result.
public class first{
public static void main(String args[]){
int a = 23;
int b = 32;
if(aSystem.out.println(a "}else{
System.out.println(a ">" b);
}
}
}
Look at this sentence in your program
Change your program to this if($_POST['submit']){echo "Your choice is
"; foreach ($_POST['select'] as $bookname) { echo "$bookname
";}} Use foreach to traverse the array output.
There is no line break in the above, which looks more laborious. hehe
Repost
if($_POST['submit']) { echo "Your choice is:
";
foreach ($_POST['select'] as $bookname) { echo "$bookname
"; }
}
The above is the detailed content of How to write the following Java program. For more information, please follow other related articles on the PHP Chinese website!