java语法问题 - Java / Java EE
import java.io.*;
class FileTest
{
public static void main(String [] args) throws Exception
{
File fDir=new File(File.separator);
String strFile="java源代码测试"+File.separator+"java2基础知识";
File f = new File(fDir,strFile);
String [] names=f.list(new FilenameFilter()
{
public boolean accept(File dir,String name)
{
if(true)
return name.indexOf(".java")!=-1;
}
});
for (int i=0;i<names.length;i++)
System.out.println(names[i]);
}
}
为什么这条语句编译不通过呢?
public boolean accept(File dir,String name)
里边,如果if不成立。返回什么?需要给出。不然编译器不让通过
你不如把if(true) 给去了算了,反正都是true了
楼上两位说的正确。把if(true)去掉就可以了。
虽然if(true)恒被执行,但是编译器还是会盘if不成立的情况,如果if不成立,就没有返回值,所有编译不过了哦
String [] names=f.list(new FilenameFilter() {
public boolean accept(File dir,String name) {
if(true)
return name.indexOf(".java")!=-1;
}
}
);
这句是什么意思啊?
正解
相关问答:
工作地点:上海张江
学历要求:大本或以上
专业要求:计算机相关专业
英语:熟练(美国项目,英语工作环境,英语是必须)
简历投递:wendy_qian@163.com
MSN:wendydzmm@hotmail.com
......
字符流的读和写最终在底层都是通过字节流来完成的吗? 读写文本文件字符流应该就可以了吧。。
各位大哥大姐帮帮忙阿
Java流包括字节流和字符流,字节流通过IO设备以字节数据的方式读入,而字符流则是通过字节流 ......
我想使用Lucene的代码,发现要import一批文件:
============
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
………………
===== ......
1 public class BirthDate {
2 private int day;
3 private int month;
4 private int year;
5
6 public BirthDate (){}
7
8 public BirthDate (int d,int m,int y){
9 day = d;
......
计算机科学与技术个人简历
基本信息
姓 名: 李炎 相片:
性 别:男
出生日期:1 ......