求JAVA源代码

2024-05-15

1. 求JAVA源代码

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class GradeStatistic {

 public static void main(String[] args) {

  GradeStatistic gs = new GradeStatistic();
  
  List list = new ArrayList();
  
  float sum = 0;
  
  while(true){
   
   Scanner sc = new Scanner(System.in);
   
   System.out.print("Please input student name: ");
   String name = sc.nextLine();
   
   if(name.equals("end")){
    break;
   }
   
   System.out.print("Please input student score: ");
   float score = sc.nextFloat();
   sum += score;
   
   list.add(gs.new Mark(name, score));
   
  }
  
  float max = list.get(0).getScore(); 
  float min = list.get(0).getScore();
  
  for(Mark mark: list){
   if(max < mark.getScore()){
    max = mark.getScore();
   }
   
   if(min > mark.getScore()){
    min = mark.getScore();
   }
   
  }
  
  float average = sum / list.size();
  
  System.out.println("Average is: " + average);
  System.out.println("Max is: " + max);
  System.out.println("Min is: " + min);
 }
 
 private class Mark{
  private String name;
  private float score;
  
  public Mark(String name, float score){
   this.name = name;
   this.score = score;
  }
  public String getName() {
   return name;
  }
  public float getScore() {
   return score;
  }
 }
}
----------------------
Please input student name: Zhang san
Please input student score: 100
Please input student name: Li Si
Please input student score: 91
Please input student name: Ec
Please input student score: 35
Please input student name: ma qi
Please input student score: 67
Please input student name: end
Average is: 73.25
Max is: 100.0
Min is: 35.0

求JAVA源代码

2. java代码分析

这个你就要看源代码了!int和Integer不是一个类型,在jdk1.5以后有了原生数据类型自动封装和拆装功能这个程序才可以实现!Jdk1.4需要强制类型钻换才可以实现!当你Integer i1=127;Integer j1=127;的时候,127属于byte类型的范围,当在这个范围封装时候他会自动指向同一个Integer,所以相等,而当超过byte的范围他就会重新生成一个Interger对象,就不等了,当然你要具体了解要自己看源代码才可以!在Eclipse里要看源代码,你按着ctrl用鼠标点击你程序中的类名就可以直接跳到源代码处!

3. 求一个oracle链接java的代码,要求能实现基本功能

jsp + servlet + jdbc的简单的学生管理系统实现登录及录入增删改查功能
需要的话,留联系方式给我!~

求一个oracle链接java的代码,要求能实现基本功能

4. 求一个JAVA代码

public void addStudent(Bean bean){
    try {

     strSQL="insert into student(name,code) values(?,?)";    
     conn=pool.getConnection();
     pstmt=conn.prepareStatement(strSQL);
     
     pstmt.setString(1, bean.getName());
     pstmt.setString(2, bean.getCode());   
     pstmt.executeUpdate();
   
  } catch (Exception e) {
   e.printStackTrace();
   // TODO: handle exception
  }finally{
   try {
    if (rs != null) {
     rs.close(); // 如果是查询操作,则需要关闭结果集
    }
    if (pstmt != null) {
     pstmt.close();
    }
    if (conn != null) {
     pool.freeConnection(conn);
    }
   }
   catch (Exception e) {
    e.printStackTrace();
   }
  }
  
 }
 
 public List getAllStudent() {
  Connection con = null;
  PreparedStatement pstmt = null;
  ResultSet rs = null;
  List searchList = new ArrayList();
  try {
   String strSQL = "select * from student" ;
   con = pool.getConnection();
   pstmt = con.prepareStatement(strSQL);
   rs = pstmt.executeQuery();  
   while (rs.next()) {    
    Bean bean = new Bean();
    bean.setName(rs.getString("name"));
    bean.setCode(rs.getString("code"));
    searchList.add(bean);
   }
  } catch (Exception e) {
  } finally {
   try {
    if (rs != null) {
     rs.close(); 
    }
    if (pstmt != null) {
     pstmt.close();
    }
    if (con != null) {
     pool.freeConnection(con);
    }
   } catch (Exception e) {
    e.printStackTrace();
   }

  }
  return searchList;
 }
 
 public Bean getOneStudent(String code) {
  Connection con = null;
  PreparedStatement pstmt = null;
  ResultSet rs = null;
    Bean bean = new Bean();
  try {
   String strSQL = "select * from student where code='" + code + "'" ;
   con = pool.getConnection();
   pstmt = con.prepareStatement(strSQL);
   rs = pstmt.executeQuery();  
   if (rs.next()) {    
    bean.setName(rs.getString("name"));
    bean.setCode(rs.getString("code"));
   }
  } catch (Exception e) {
  } finally {
   try {
    if (rs != null) {
     rs.close(); 
    }
    if (pstmt != null) {
     pstmt.close();
    }
    if (con != null) {
     pool.freeConnection(con);
    }
   } catch (Exception e) {
    e.printStackTrace();
   }

  }
  return bean;
 }

5. 求java代码

package com.baidu;import java.io.*;import java.util.*;/** * date :  Dec 29, 2013 * * time :  10:07:15 AM * * author : Spole * */public class Demo04 {       //要排列组合的元素个数       private static int MAX_INDEX;       //当前排列中需要填入数字的索引位置       private static int finishIndex;       //已经完成的排列的数量       private static int finishCount;       //记录排列元素的数组       private int[] num;       //当前的排列组合       private LinkedList savedNum;       public Demo04(int max)       {              MAX_INDEX = max;              finishIndex = 0;              finishCount = 0;              num = new int[MAX_INDEX];              savedNum = new LinkedList();              for(int i=0; i<MAX_INDEX; i++)              {                     num[i] = i+1;              }       }       public void doPermutationAndCombination()       {              saveNum(num);              System.out.println("一共 " + finishCount + "种组合!");       }       //完成排列组合,并输出到屏幕       private void saveNum(int[] num)       {              //循环数量由所处的递归层数决定              for(int i=0; i<MAX_INDEX-finishIndex; i++)              {                     //添加选中的元素到链表                     savedNum.addLast(num[i]);                     //记录已经选取的元素                     int numBuf = num[i];                     //记录以完成的排列组合数量                     if(finishIndex == (MAX_INDEX-1))                     {                            finishCount++;                     }                     //创建传入递归下一层要用的数组                     int nextNum[] = new int[MAX_INDEX - (finishIndex+1)];                     int m = 0;                     //拷贝未选用的数字                     for(int n=0; n<MAX_INDEX-finishIndex; n++)                     {                            if(num[n] == numBuf)                            {                                   continue;                            }                            else                            {                                   nextNum[m] = num[n];                                   m++;                            }                     }                     //是否继续递归                     if((MAX_INDEX - (finishIndex+1)) != 0)                     {                            //递归层数计数加1                            finishIndex++;                            saveNum(nextNum);                     }                     else                     {                            //输出这一轮递归生成的数字组合                            System.out.println(savedNum);                     }              }              try              {                     //判断是否是递归的最后一层                     if(finishIndex == (MAX_INDEX-1))                     {                            //移除排列组合的最后一位元素                            savedNum.removeLast();                            //移除排列组合的最后一位元素                            savedNum.removeLast();                     }                     else                     {                            //移除排列组合的最后一位元素                            savedNum.removeLast();                     }              }              catch(Exception e){}              finally              {                     //回到上一层,递归层数要减1                     finishIndex--;              }       }       public static void main(String[] args)       {              String theMaxString = null;              int theMax = 0;              try              {                     System.out.print("请输入数字: ");                     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));                     theMaxString = br.readLine().trim();              }              catch(Exception e)              {                     e.printStackTrace();              }              try              {                     theMax = Integer.parseInt(theMaxString);              }              catch(Exception e)              {                     System.out.println("输入的数字格式不正确!");              }              Demo04 p = new Demo04(theMax);              Date date = new Date();              p.doPermutationAndCombination();              System.out.println("用时" + (new Date().getTime() - date.getTime()) + "毫秒");       }}

求java代码

6. 关于JAVA代码

clone()是Object类的一个方法,跟toString()、equals()的地位等一样。其目的是深拷贝,返回一个新的Object的对象,且该对象和Object本身一样。
有两种拷贝:深拷贝(deep copy)、浅拷贝(shallow copy)。浅拷贝只是把当前对象的reference传回,深拷贝则是返回一个新的对象。

7. 关于java判断的问题,如下代码 实现什么功能

人生总是多磨难,世事无常难抉择。逃避只是短暂瞬间,命运不会从此改写;缘分需要珍惜,强求不是好手段;放弃有时也是必然,愿你人生辉煌呈现。。。探讨。解惑。10 。40。65。99。88.非诚。勿扰。。这个行业看似简单实际上存在很大的难度不是我们起初想像的那么简单 做这个行业首先你要会运用谎言而且谎言的技术要非常高明。不用谎言,很难把人邀约去的。即使邀约去,不管人家认可不认可,在那里考察期间的生活费,你要支出。实际上,邀约去十个也不一定留下一个,光是招待费就非常令人头痛为什么留不下人一是联锁销售的负面影响太大了很多人都认为那是传消二是有些人根本不具备从事的条件工作不能辞家人不理解投入又大。加上你自己要吃喝,租住房屋,坐车来回的路费,招待朋友的费用生活上的不便邀约不成功等等精神压力经济压力会越来越大。我们投入的都是血钱,而且我们的人际资源非常有限,就是有数的几个亲戚朋友。等你的运作资金用完了,你的人脉用完了。你也就到了山穷水尽的地步。有的人不考虑自己的实际情况,盲目从事。借钱,甚至借从事。辞去工作,不给自己留下后路。家里人的劝说也不听,弄的关系非常紧张有的因为从事这个行业,夫妻离婚父子不和。不要总是听说某某上总了。上总只是达到了600份,这个过程比较漫长。但也并不代表就赚钱了。如果伞下不发展,照样没有一分钱可拿不要听说有什么保底工资,上总后有什么六位数之类的话。你没加入前,一切都说的很好听,等你加入后,完全是两码事。而且人际市场非常容易被破坏,有不认可的回来,逢人便说你欺骗他。一传十,十传百,你的亲戚朋友很快就知道你在用谎言邀约别人。我们的人脉本来就少 ?如果再出现这样的情况,人际市场基本就完了有的为了做高起点用。结果不但本钱没回来,还负债累累。无法返回家乡,无脸见亲戚朋友,为了做高起点,把房子卖掉无家可归夫妻反目为仇妻离子散。适合自己的才是最有效的。异地经过十四的运作,模式存在太多的弊端,已经不适应现在的社会了。现在的社会是信息社会,是电子商务的时代。有头脑的人,都会审视yi地的弊端,而选择一个更适合自己从事的项目行业是个不错的项目可就是因为存在太多的弊端不适合大多数人从事。我们的确想翻身,想找一个更好的适合自己的项目从事。毕竟现在的传统项目不大赚钱了,打工累死累活最后一无所获,上班就是一个月的一两千元的工资生活开支又大哪里够花销啊。。探讨。解惑。1 0。53。56 0。726。  非诚。勿扰。。你也好好想想吧!

关于java判断的问题,如下代码 实现什么功能

8. 求一段java代码作用

公共类学生{
私人字符串名称; 
私人诠释的年龄; 
 
公益助学(){
} 
 
公益助学(字符串名称,诠释年龄){
 this.name =名称; 
 this.age =年龄; 
 
 @覆盖
公共字符串的toString(){
回归“名称:”+姓名+“,年龄:”+年龄; 
 公共字符串getName(){
;返回名称; 
 公共无效的setName(字符串名称){
 this.name =名称; 
}  
公众诠释getAge(){
回报岁; } 
 
公共无效setAge(智力年龄){
; this.age =年龄; 
 公众;静态无效的主要(字串[] args){
尝试{
学生学生=(学生)的Class.forName(“学生”)的newInstance();。 
 student.setName(“鲍勃”); 
; student.setAge(18); 
 System.out的。的println(student.toString()); 
}赶上(InstantiationException五){
 e.printStackTrace(); 
}赶上; (IllegalAccessException E){
 e.printStackTrace(); 
;}赶上(ClassNotFoundException异常E){
 e.printStackTrace(); 
 }
最新文章
热门文章
推荐阅读