| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 484 人关注过本帖
标题:字符串可否转化为字符(数组)
只看楼主 加入收藏
lzyren2008
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2007-8-12
收藏
 问题点数:0 回复次数:2 
字符串可否转化为字符(数组)

字符串可否转化为字符(数组),如果字符串只有一个字符,如何转化为一个char类型的,谢谢!

搜索更多相关主题的帖子: 字符 
2007-09-19 08:39
hwoarangzk
Rank: 4
来 自:冰封王座
等 级:贵宾
威 望:12
帖 子:1894
专家分:0
注 册:2007-7-17
收藏
得分:0 

能,用getChars()方法:
getChars
public void getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)Copies characters from this string into the destination character array.
The first character to be copied is at index srcBegin; the last character to be copied is at index srcEnd-1 (thus the total number of characters to be copied is srcEnd-srcBegin). The characters are copied into the subarray of dst starting at index dstBegin and ending at index:


dstbegin + (srcEnd-srcBegin) - 1

Parameters:
srcBegin - index of the first character in the string to copy.
srcEnd - index after the last character in the string to copy.
dst - the destination array.
dstBegin - the start offset in the destination array.
Throws:
IndexOutOfBoundsException - If any of the following is true:
srcBegin is negative.
srcBegin is greater than srcEnd
srcEnd is greater than the length of this string
dstBegin is negative
dstBegin+(srcEnd-srcBegin) is larger than dst.length


I'm here, as always...
2007-09-19 09:13
小小J人
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2007-9-19
收藏
得分:0 
在String类当中提供了方法将一个串转化为字符数组!
viod getChar(int srBegin,int srcEnd,char[] dst,int dstBegin) 将字符从此字符串复制到目标字符数组
char[] toCharArray();将次字符串转化为一个新的字符数组。
2007-09-19 11:26
快速回复:字符串可否转化为字符(数组)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016511 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved