java从密码框里取出数据 char[] s2 = this.jPasswordField1.getPassword(); 怎样把数组里值转换成String型

[复制链接]
查看11 | 回复5 | 2011-6-22 16:56:12 | 显示全部楼层 |阅读模式
高手们写明白点

回复

使用道具 举报

千问 | 2011-6-22 16:56:12 | 显示全部楼层
char[] 数组转换成String可使用new String(char[]);或String.valueOf(char[]); ,在使用swing的JPasswordField组件时,getPassword()得到的就时char数组。知道你就是要把它转化为String (处理起来方便)给你写个简单测试:public static void main(String[] args) {
char[] c = {'a', 'b', 'c', 'd'};
String s1 = new String(c);
String s2 = String.valueOf(c);
...
回复

使用道具 举报

千问 | 2011-6-22 16:56:12 | 显示全部楼层
在你写的这句话下面加一句String b=Arrays.toString(s2);...
回复

使用道具 举报

千问 | 2011-6-22 16:56:12 | 显示全部楼层
String password=String.copyValueOf(jPasswordField1.getPassword(); 这样就能实现你想要的结果了!...
回复

使用道具 举报

千问 | 2011-6-22 16:56:12 | 显示全部楼层
Stringstr = new String(s2);...
回复

使用道具 举报

千问 | 2011-6-22 16:56:12 | 显示全部楼层
Arrays.toString(数组引用)...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行