for(i=1i<=4i++)
{
这个小的for是打印每一行前边的空格
for(j=1j<=4-ij++)
System.out.print(" ")
这个是打印星星的
for(j=1j<=2*i-1j++)
System.out.print("*"碧数)
这个是打印完一行的换行
System.out.println("")
}
下边的是一样的 只不过每一行的空格悔纤首和星星数 和上边竖则是翻过来的
for(i=1i<=3i++)
{
for(j=1j<=ij++)
System.out.print(" ")
for(j=1j<=7-2*ij++)
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()
//连接数据库
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()
public class Diamond1 {public static void main(String[] args) {
// TODO 自动生成的方法存根
String m=" "
for(int a=0a<4a++){//控制行数,为后面的公式定基数
for(int b=4-ab>=0b--){
System.out.print(m)//输出*之前的空格
}for(int c=2*a-1c>-2c--){
System.out.print("*")//输出对应洞瞎行数的*数目
}System.out.println()/纳衫空/换行
}//菱形上半部分
for(int A=4A<7A++){//控制行数,为后面的公式定基数
for(int B=A-3B>=-1B--){
System.out.print(m)//输出*之前的空格
}for(int C=13-2*AC>0C--){
System.out.print("*"塌槐)//输出对应行数的*数目
}System.out.println()//换行
}//菱形下半部分
}
}
手打~~
public class Var_02 {public static void main(String args[])
{
//进入循环体
/*
*第一次,当i=1的时候 ,进入,
*
*/
for (int i = 1i <= 7i += 2)
{
/*
* 这个for循环是打的空白。就是说。当第一行打一个星之前的时候
*
* 这里首先要先开始打七个空白处
*
* 然后由于星星每下一行要多打,所以第二搭橘喊个for里面就要递增的方式
*
* 星星越来越多。相对的空白就越来越少了。
*
*/
for (int kong = 7kong >i - 1kong--)
{
System.out.print(" ")
}
for (int xing = 1xing <= ixing++)
{
System.out.print("* ")
}
System.out.println()
}
/*
*
* 底下的这个循环到底和上面的相反的。
*
* 是先空白打的少。然后星星就打的多。
*/
for (int j = 1j <= 5j += 2)
{
for (int kong1 = 1kong1 <j + 3kong1++)
{
System.out.print(" ")
}
for (int xing1 = 5xing1 >= jxing1--)
{
System.out.print("* ")
}
System.out.println()
}
}
}其实这个菱形就是两个三角形知野在一起伍袭。上面是个正三角形,先打空白出来。依次减少空白。星星相反的慢慢增多而下面的是倒三角形。也是先打空白。依次增多空白。星星也相反的慢慢减少
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)