for(i=1;i=4;i++)
我們提供的服務有:網(wǎng)站建設、做網(wǎng)站、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認證、平塘ssl等。為上千家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術的平塘網(wǎng)站制作公司
{
這個小的for是打印每一行前邊的空格
for(j=1;j=4-i;j++)
System.out.print(" ");
這個是打印星星的
for(j=1;j=2*i-1;j++)
System.out.print("*");
這個是打印完一行的換行
System.out.println("");
}
下邊的是一樣的 ?只不過每一行的空格和星星數(shù) ? 和上邊是翻過來的
for(i=1;i=3;i++)
{
for(j=1;j=i;j++)
System.out.print(" ");
for(j=1;j=7-2*i;j++)
System.out.print("*");
System.out.println("");
}
java.sql.SQLException: 無效的列索引
無效的列索引
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:207)
atoracle.jdbc.driver.OraclePreparedStatement.setStringInternal(OraclePreparedStatement.java:5328)
atoracle.jdbc.driver.OraclePreparedStatement.setString(OraclePreparedStatement.java:5320)
at untitled5.addreader1.validID(addreader1.java:128)
at untitled5.addreader1.jButton1_actionPerformed(addreader1.java:97)
at untitled5.addreader1_jButton1_actionAdapter.actionPerformed(addreader1.java:175)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
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)
代碼:String driverName = "oracle.jdbc.OracleDriver";
Driver driver = (Driver) Class.forName(driverName).newInstance();
//連接數(shù)據(jù)庫
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();
參考下面主要代碼:\x0d\x0apublicstaticvoiddraw()\x0d\x0a{\x0d\x0aintn=10;\x0d\x0afor(inti=1;i=i;k--)//打印空格\x0d\x0a{\x0d\x0aSystem.out.print("");\x0d\x0a}\x0d\x0afor(intj=1;j=1;i--)\x0d\x0a\x0d\x0a{\x0d\x0afor(intk=i;k
回答于?2022-12-14
代碼如下:
/**
*
*/
package main;
/**
* @author GT
*
*/
public class Mains {
/**
*
*/
public Mains() {
// TODO Auto-generated constructor stub
}
public static void print(int size) {
if (size % 2 == 0) {
size++; // 計算菱形大小
}
for (int i = 0; i size / 2 + 1; i++) {
for (int j = size / 2 + 1; j i + 1; j--) {
System.out.print(" "); // 輸出左上角位置的空白
}
for (int j = 0; j 2 * i + 1; j++) {
System.out.print("*"); // 輸出菱形上半部邊緣
}
System.out.println(); // 換行
}
for (int i = size / 2 + 1; i size; i++) {
for (int j = 0; j i - size / 2; j++) {
System.out.print(" "); // 輸出菱形左下角空白
}
for (int j = 0; j 2 * size - 1 - 2 * i; j++) {
System.out.print("*"); // 輸出菱形下半部邊緣
}
System.out.println(); // 換行
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
print(11);
}
}