class StringTest4
{
public static void main(String[] args)
{
String s=" ab c ";
s=myTrim(s);
System.out.println("s="+s);
}
public static String myTrim(String s)
{
int start=0;
int end=s.length()-1;
while (start<=end && s.charAt(start)==' ')
{
start++;
}
while (start<=end &&s.charAt(end)==' ')
{
end--;
}
return s.substring(start,end+1);
}}
编译不过咋回事?
{
public static void main(String[] args)
{
String s=" ab c ";
s=myTrim(s);
System.out.println("s="+s);
}
public static String myTrim(String s)
{
int start=0;
int end=s.length()-1;
while (start<=end && s.charAt(start)==' ')
{
start++;
}
while (start<=end &&s.charAt(end)==' ')
{
end--;
}
return s.substring(start,end+1);
}}
编译不过咋回事?
解决方案 »
- 自己写的求质数的代码
- HttpURLConnection.setRequestProperty不能设置authorization header???
- synchronized与singleton
- dom4j xmlns:soap 解析不了
- java中读EXECL文件问题?
- ArrayList.toArray如何返回指定类型的数组
- 请教显示HTML文件时为什么有些图片出不来?
- 一个《车迷世界》软件
- 请问有没有办法判断文件是不是文本格式存储的。用java。但是不能依靠后缀名。。。
- JAVA的说明文档在哪里下阿?(JAVA.SUN.COM上)
- 请问文件的大小和占用空间不一样是怎么回事?
- JSON : No converter found for return value of type
public class Test { public static void main(String[] args)
{
}
}
class StringTest4
{
public static void main(String[] args)
{
String s=" ab c ";
s=myTrim(s);
System.out.println("s="+s);
}
public static String myTrim(String s)
{
int start=0;
int end=s.length()-1;
while (start<=end && s.charAt(start)==' ')
{
start++;
}
while (start<=end &&s.charAt(end)==' ')
{
end--;
}return s.substring(start,end+1);
}}
因为你用的是默认修饰符修饰,所以是不能执行的。
如果二楼所说编译没有问题,那么就不是语法问题,就是public的问题。
{}
文件名和class名一致