怎样编写java程序,编写一个JAVA程序

1,编写一个JAVA程序for (int i = 0; i < 2; i++)for (int j = 1; j <= 4; j++) for (int k = 1; k <= j; k++)// 打印每行的* System.out.print("*"); } System.out.println(); }}
2 , JAVA怎么编啊public class Person {// 类的声明 private String head = "头";// 成员变量 private String hand = "手";// 成员变量 public void write() {// 成员方法System.out.println(hand + "可以写字"); } public void think() {// 成员方法System.out.println(head + "可以思考"); } public static void main(String[] args) {Person p = new Person();// 创建对象String shou = p.hand;// 调用成员变量String tou = p.head;// 调用成员变量p.think();// 调用成员方法p.write();// 调用成员方法 }}
3,JAVA 如何编程package com.union.service.product.Impl;import java.io.Serializable;import java.util.List;import com.union.dao.HibernateEntityDao;import com.union.model.UnionSiteProductList;import com.union.service.product.UnionSiteProductRemoveService;public class UnionSiteProductRemoveServiceImpl extends HibernateEntityDao<UnionSiteProductList>implements UnionSiteProductRemoveServicepublic void UnionSiteRemoveById(Long id)// TODO Auto-generated method stubthis.removeById(id);}}这就是java编程【怎样编写java程序,编写一个JAVA程序】
4,在java里怎么编写一个程序public class Test extends JFrame UserCertification uc; String url; Connection con; public Test(String title)setTitle(title);uc=new UserCertification();Container c=getContentPane();c.setLayout(new BorderLayout());c.add(uc,BorderLayout.CENTER);setSize(400,250);tryurl="jdbc:odbc:aaa";Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");con=DriverManager.getConnection(url);uc.jtusername.setText("恭喜!数据库连接成功!");}catch(Exception e)e.printStackTrace();}show(); } public static void main(String args[])Test test=new Test("登录界面");test.addWindowListener(new MyWindowListener()); }}class UserCertification extends JPanel{5,编写JAVA程序int sum0 = 0;for(int i = 0; i < 99; i ++)sum0 += 2*(i+1)-1;}System.out.println(sum0);int sum1 = 0;int i = 0;while(i < 99)sum1 += 2*(i+1)-1;i ++;}System.out.println(sum1);int sum2 = 0;int j = 0;dosum2 += 2*(j+1)-1;j ++;}while(j < 99);System.out.println(sum2);int s=0,s1=0;for(int i=1;i<=100;i++)s+=s1;}----------------int i=1;while(i<=100)s+=s1;i++;}-----------------------dos+=s1;i--;}while(i==0)for (int i=0;i<100;i++) tamp=(i*2)++;}Systeml.out.println(tamp);}}先进入cmd 里面 在java 目录下输入 javac filename.java(filename是你的文件名) 如果编译没有错误的话 输入 java filename 就可以了

    推荐阅读