package cn.itcast.jk;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONArray;
public class Test
{
public static void main(String[] args)
{
User user = new User();
user.setId(0);
user.setPassword("123456");
user.setQuanxian(1);
user.setUsername("zhangsan");
System.out.println(user);
String[] a = {"1","2","3"};
for (String string : a)
{
System.out.println(string);
}
List list = new ArrayList<String>();
list.add("q");
list.add("w");
list.add("e");
System.out.println(list);
List list2 = new ArrayList<String>();
list2.add("q1");
list2.add("w1");
list2.add("e1");
list2.add("r1");
list2.add("t1");
// System.out.println(list2);
List list3 = new ArrayList();
list3.addAll(list);
list3.addAll(list2);
System.out.println(list3);
HashMap<Map<String,String>,Object> map = new HashMap<Map<String,Object>();
Map<String,String> map1 = new HashMap<String,String>();
map1.put("1","1");
Map<String,String> map2 = new HashMap<String,String>();
map2.put("2","2");
Map<String,String> map3= new HashMap<String,String>();
map3.put("3","3");
map.put(map1,"asda");
map.put(map2,"hfdg");
map.put(map3,"fghfg");
System.out.println(map);
String objJson = JSONArray.toJSONString(user);
System.out.println(objJson);
}
}
-----------------------------------------------------------------------------------------------
package cn.itcast.jk;
/**
* User entity. @author MyEclipse Persistence Tools
*/
public class User implements java.io.Serializable {
// Fields
private Integer id;
private String username;
private String password;
private Integer quanxian;
// Constructors
/** default constructor */
public User() {
}
/** full constructor */
public User(String username,String password) {
this.username = username;
this.password = password;
}
// Property accessors
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getpassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getQuanxian()
{
return quanxian;
}
public void setQuanxian(Integer quanxian)
{
this.quanxian = quanxian;
}
@Override
public String toString()
{
return "User [id=" + id + ",username=" + username + ",password=" + password + ",quanxian=" + quanxian + "]";
}
}
----------------------------------------------------------------打印结果-------------------------------------------------------------------------------------
User [id=0,username=zhangsan,password=123456,quanxian=1]123[q,w,e][q,e,q1,w1,e1,r1,t1]{{3=3}=fghfg,{2=2}=hfdg,{1=1}=asda}{"id":0,"password":"123456","quanxian":1,"username":"zhangsan"}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。