JAVA高手进~急 在线等。。。

写一个带构造方法和set、get方法类。并测试之。4、编写一个带continue的程序。5、编写一个程序统计一个文件字符的个数还有行数6、统计一个字符串里数字字符的个数7... 写一个带构造方法和set、get方法类。并测试之。
4、编写一个带continue的程序。
5、编写一个程序统计一个文件字符的个数还有行数
6、统计一个字符串里数字字符的个数
7、将一个字符串逆序输出

能写出几个就写几个。。。谢谢~
展开
 我来答
yp0123456789
2010-06-29 · TA获得超过782个赞
知道小有建树答主
回答量:457
采纳率:0%
帮助的人:352万
展开全部
public class Userinfo implements java.io.Serializable {

// Fields

private Integer userinfoid;
private Empinfo empinfo;
private String username;
private String password;
private Integer userstate;

// Constructors

/** default constructor */
public Userinfo() {
}

/** full constructor */
public Userinfo(Empinfo empinfo, String username, String password,
Integer userstate) {
this.empinfo = empinfo;
this.username = username;
this.password = password;
this.userstate = userstate;
}

// Property accessors

public Integer getUserinfoid() {
return this.userinfoid;
}

public void setUserinfoid(Integer userinfoid) {
this.userinfoid = userinfoid;
}

public Empinfo getEmpinfo() {
return this.empinfo;
}

public void setEmpinfo(Empinfo empinfo) {
this.empinfo = empinfo;
}

public String getUsername() {
return this.username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return this.password;
}

public void setPassword(String password) {
this.password = password;
}

public Integer getUserstate() {
return this.userstate;
}

public void setUserstate(Integer userstate) {
this.userstate = userstate;
}

}
fylsh
2010-06-29 · TA获得超过950个赞
知道小有建树答主
回答量:1472
采纳率:0%
帮助的人:1137万
展开全部
public class Student{
public Student(){
}
private String name;
public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}

}

public class Test{
Student s=new Student();
s.setName("fylsh");
System.out.println(s.getName());
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
科技极客观
2010-06-29 · 超过35用户采纳过TA的回答
知道小有建树答主
回答量:148
采纳率:0%
帮助的人:108万
展开全部
/**
* author: Flying
* createTime: 12:39:20 AM
* version:1.0
* 功能:1 读取文件或文件夹,输出行数和字符数
* 2.文件内容逆序输出
*/
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class CharTest
{
// 可以是文件夹,也可以是文件
private static String filePath = "c:/test";

// private static String filePath = "c:/test.txt";

public static void main(String[] args)
{
CharTest charTest = new CharTest();
File file = new File(filePath);
// 文件或文件夹不存在,自动创建
if (!file.exists())
{
System.out.println("目录 " + file.getName() + " 不存在,自动创建");
file.mkdirs();
}
// 如果file是个文件,直接输出
if (file.isFile())
{
charTest.parseFile(file);
}
// 如果是目录,则输出目录下所有文件的内容
else
{
File[] files = file.listFiles();
if (files.length == 0)
{
System.out.println("目录" + filePath + "下没有文件,请创建。");
}
for (File f : files)
{
charTest.parseFile(f);
System.out.println("-----------------------------------------------------");
}
}
}

// 解析文件输出行数和字符数
public void parseFile(File file)
{
FileReader fr = null;
BufferedReader br = null;
try
{
fr = new FileReader(file);
br = new BufferedReader(fr);
@SuppressWarnings("unused")
String line = null;
long lineCount = 0;
long charCount = 0;
String str = "";
while ((line = br.readLine()) != null)
{
lineCount++;
charCount += line.length();
str = str + line;

}
System.out.println("开始逆序输出文件: " + file.getName() + "的内容:");
reversStr(str);// 逆序输出文件内容

System.out.println("文件名: " + file.getName() + " 共有:" + lineCount + "行;" + charCount + "个字符");
fr.close();
br.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}

}

// 逆序输出字符串内容
public void reversStr(String str)
{
for (int i = str.length() - 1; i >= 0; i--)
{
System.out.print(str.charAt(i));
}
System.out.println("");
}

}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式