at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
代码java打出菱形代码:String driverName = "oracle.jdbc.OracleDriver";
Driver driver = (Driver) Class.forName(driverName).newInstance();
//连接数据库
Connection con = DriverManager.getConnection(
"jdbc:oracle:thin:@LONG:1521:orcl", "sysman", "tongfang");
PreparedStatement pstmt = con.prepareStatement(
" insert into reader values(?)");
pstmt.setString(1, str1);
pstmt.setString(2,str2);
pstmt.setString(3,str3);
pstmt.setString(4,str4);
ResultSet res = pstmt.executeQuery();
怎么用java打印菱形?java打印菱形方法java打出菱形代码:
package circulationDemo;
import java.util.Scanner;
public class Test {
【java打出菱形代码 java编程输出菱形图案】public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入要打印java打出菱形代码的行数:");
int num = input.nextInt();
t1(num);// 正直角
split();
t2(num);// 倒直角
split();
t3(num);// 等腰三角
split();
t4(num);// 等腰倒三角++
split();
t5(num);// 等腰倒三角--
split();
t6(num);// 实心菱形
split();
t7(num);// 空心菱形(1)
split();
t8(num);// 空心菱形(2)
split();
t9(num);// 空心菱形(3)
}
private static void t9(int num) {
for (int k = 1; k = num; k++) {
for (int i = 1; i = (num - k); i++) {
System.out.print(" ");
}
System.out.print("*");
for (int i = 1; i = ((k - 2) * 2 + 1); i++) {
System.out.print(" ");
}
if (k != 1) {
System.out.print("*");
}
System.out.println();
}
for (int k = num-1; k = 1; k--) {
for (int i = 1; i = (num - k); i++) {
System.out.print(" ");
}
System.out.print("*");
for (int i = 1; i = ((k - 2) * 2 + 1); i++) {
System.out.print(" ");
}
if (k != 1) {
System.out.print("*");
}
System.out.println();
}
}
private static void t8(int num) {
// 上半部分
for (int i = 1; i = num; i++) {
// 打印上半部分空格
for (int j = 1; j = num - i; j++) {
System.out.print(" ");
}
// 打印原本实心java打出菱形代码的*部分
for (int j = 1; j = 2 * i - 1; j++) {
// 仅在一行的开头和末尾打印*
if (j == 1 || j == 2 * i - 1) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
// 下半部分
for (int i = 1; i = num - 1; i++) {
for (int j = 1; j = i; j++) {
System.out.print(" ");
}
for (int j = 1; j = 2 * (num - i - 1) + 1; j++) {
if (j == 1 || j == 2 * (num - i - 1) + 1) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
private static void t7(int num) {
// 打印上半部分
for (int i = 1; i = num; i++) {
// 打印空格
for (int j = 1; j = (num - i); j++) {
System.out.print(" ");
}
// 打印*的个数
if (i == 1) {
System.out.print("*");
} else {
System.out.print("*");
// 打印菱形里的空格
for (int j = 1; j = (2 * i - 3); j++) {
System.out.print(" ");
}
System.out.print("*");
}
System.out.println();
}
// 打印下半部分
for (int i = num - 1; i0; i--) {
// 打印空格
推荐阅读
- 直播中福袋用电脑怎么发,直播中福袋用电脑怎么发送
- 拍摄电影什么镜头好,拍摄电影什么镜头好用
- sap外币评估历史记录,sap外币评估没有生成凭证
- 直播新西兰吃美食的主播,直播新西兰吃美食的主播叫什么
- go语言class类 go语言数据类型
- 怎么把u盘显示,怎么把u盘显示在桌面
- linux命令的英文全拼,linux必学的60个命令怎么读起来简单
- 理解java代码的技巧 java代码基本结构
- 鸿蒙更新系统参数,鸿蒙最新升级数据