【发布时间】:2011-11-28 18:59:58
【问题描述】:
我有一个方法可以将一堆字符发送到另一个方法,如果存在某个字符,该方法将返回 true 或 false。一旦此方法评估所有字符并为每个字符返回 true 或 false,我如何在另一个方法中使用这些 true 或 false 值? 我想我有一次发送一个字符的方法。布尔方法不是布尔数组。
public void Parse(String phrase)
{
// First find out how many words and store in numWords
// Use "isDelim()" to determine delimiters versus words
//
// Create wordArr big enough to hold numWords Strings
// Fill up wordArr with words found in "phrase" parameter
int len = phrase.length();
char[] SeperateString = new char[len];
for (int i = 0; i < len; i++) {
SeperateString[i] = phrase.charAt(i);
isDelim(SeperateString[i]);
System.out.println(SeperateString[i]);
boolean isDelim(char c)
{
{
if (c == delims[0])
return true;
else if (c == delims[1])
return true;
else if (c == delims[2])
return true;
else
return false;
}
//Return true if c is one of the characters in the delims array, otherwise return false
}
【问题讨论】:
-
发布您的代码。你的问题不清楚。
-
您是一次发送
collection个字符,还是逐个发送字符?该方法是返回一个collection的布尔值还是一个一个地返回布尔值? -
该方法返回的是布尔数组还是单个布尔值?
-
你不能在另一个方法 (Parse) 中定义一个方法 (isDelim)。