易截截图软件、单文件、免安装、纯绿色、仅160KB

Java基础——java的引用问题

1.
public class EasyError1 {
     class Student {
           private String name;
 
           public String getName() {
              return name;
           }
 
           public void setName(String name) {
              this.name = name;
           }
           }
public List<Student> getList(List<String> names){
    List<Student> studentList=new ArrayList<Student>();
    Student student=new Student();
    for(String str:names){
       student.setName(str);
       studentList.add(student);
    }
    return studentList;
}
public static void main(String[] args) {
    EasyError1 easyError1=new EasyError1();
    List<String> list=new ArrayList<String>();
    list.add("pitt");
    list.add("tom");
    list.add("weiling");
List<Student> studentList=  easyError1.getList(list);
for(Student student:studentList){
    System.out.println(student.getName());
}
}
}
/******************************************************
 * the results in console:
 *  weiling
 *  weiling
 *  weiling
 *因为Student student=new Student();写在了循环的外面,在循环里每次都把名字放在了一块堆内存里,并把引用
 *存放在了list中,只是一个引用,而不是三个不同的引用存放在list中,最后,这个引用只想向了“


相关文档:

提取汉字拼音首字母(Java版)

package info.gnuhpc;
/**
* @author gnuhpc email: warmbupt@gmail.com blog: http://gnuhpc.info
* @date 2010-1-22
* @bugs 不支持多音字处理
*/
public class PinyinConv {
// 简体中文的编码范围从B0A1(45217)一直到F7FE(63486)
private static int BEGIN = 45217;
private static int ......

Java平台I18N 支持概述

一、国际化和 Java 编程语言
 
和大多数使用其它语言的程序员不同,Java
程序员是大量构建在 JDK 中提供 I18N 支持的标准代码的受益者。大部分代码最初来自 IBM 的 Taligent 子公司(自从合并进
IBM 以后),代表了许多人年的工作成果,比大多数公司独自在其产品中提供的代码要切实可行得多。
 
这些
代码 ......

java的一些常用包

commons-digester.jar
Digester基于规则的XML文档解析,主要用于XML到Java对象的映射.
commons-beanutils.jar
提供对Java 反射和自省API的包装.
aspectjweaver.jar
用于在Spring 2.0中集成AspectJ AspectJ LTW织入器
ognl.jar
OGNL是Object-Graph Navigation Language的缩写,它是一种功能强大的表达式语言(E ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号