How to write the following Java program

WBOY
Release: 2024-01-17 15:21:17
forward
1229 people have browsed it

How to write the following Java program

How to write the following java program

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);

}

}

}

Ask a question about php value

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!

Related labels:
source:docexcel.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!