sunjava源代码 javascanner源码

高分求两个简单的JAVA设计源代码上面 wuzhikun12同学写的不错 , 但我想还不能运行,并且还不太完善 。我给个能运行的:(注意:文件名为:Test.java)
//要实现对象间的比较 , 就必须实现Comparable接口,它里面有个compareTo方法
//Comparable最好使用泛型,这样,无论是速度还是代码量都会减少
@SuppressWarnings("unchecked")
class Student implements ComparableStudent{
private String studentNo; //学号
private String studentName; //姓名
private double englishScore; //英语成绩
private double computerScore; //计算机成绩
private double mathScore; //数学成绩
private double totalScore; //总成绩
//空构造函数
public Student() {}
//构造函数
public Student(String studentNo,String studentName,double englishSocre,double computerScore,double mathScore) {
this.studentNo = studentNo;
this.studentName = studentName;
this.englishScore = englishSocre;
this.computerScore = computerScore;
this.mathScore = mathScore;
}
//计算总成绩
public double sum() {
this.totalScore = englishScore computerScore mathScore;
return totalScore;
}
//计算评测成绩
public double testScore() {
return sum()/3;
}
//实现compareTO方法
@Override
public int compareTo(Student student) {
double studentTotal = student.getTotalScore();
return totalScore==studentTotal?0:(totalScorestudentTotal?1:-1);
}
//重写toString方法
public String toString(){
return "学号:" this.getStudentNo() " 姓名:" this.getStudentName() " 英语成绩:" this.getEnglishScore() " 数学成绩:" this.getMathScore() " 计算机成绩:" this.getComputerScore() " 总成绩:" this.getTotalScore();
}
//重写equals方法
public boolean equals(Object obj) {
if(obj == null){
return false;
}
if(!(obj instanceof Student)){
return false;
}
Student student = (Student)obj;
if(this.studentNo.equals(student.getStudentName())) { //照现实来说 , 比较是不是同一个学生,应该只是看他的学号是不是相同
return true;
} else {
return false;
}
}
/*以下为get和set方法 , 我个人认为,totalScore的set的方法没必要要,因为它是由其它成绩计算出来的
在set方法中,没设置一次值 , 调用一次sum方法,即重新计算总成绩
*/
public String getStudentNo() {
return studentNo;
}
public void setStudentNo(String studentNo) {
this.studentNo = studentNo;
sum();
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
sum();
}
public double getEnglishScore() {
return englishScore;
}
public void setEnglishScore(double englishScore) {
this.englishScore = englishScore;
sum();
}
public double getComputerScore() {
return computerScore;
}
public void setComputerScore(double computerScore) {
this.computerScore = computerScore;
sum();
}
public double getMathScore() {
return mathScore;
}
public void setMathScore(double mathScore) {
this.mathScore = mathScore;
sum();
}
public double getTotalScore() {
return totalScore;
}
}
//Student子类学习委员类的实现
class StudentXW extends Student {
//重写父类Student的testScore()方法
@Override
public double testScore() {
return sum()/3 3;
}
public StudentXW() {}
//StudentXW的构造函数
public StudentXW(String studentNo,String studentName,double englishSocre,double computerScore,double mathScore) {
super(studentNo,studentName,englishSocre,computerScore,mathScore);
}
}
//Student子类班长类的实现
class StudentBZ extends Student {
//重写父类Student的testScore()方法
@Override
public double testScore() {
return sum()/3 5;
}
public StudentBZ() {}
//StudentXW的构造函数
public StudentBZ(String studentNo,String studentName,double englishSocre,double computerScore,double mathScore) {
super(studentNo,studentName,englishSocre,computerScore,mathScore);
}
}
//测试类
public class Test {
public static void main(String[] args) {
//生成若干个student类、StudentXW类、StudentBZ类
Student student1 = new Student("s001","张三",70.5,50,88.5);
Student student2 = new Student("s002","李四",88,65,88.5);
Student student3 = new Student("s003","王五",67,77,90);
StudentXW student4 = new StudentXW("s004","李六",99,88,99.5);
StudentBZ student5 = new StudentBZ("s005","朱漆",56,65.6,43.5);
Student[] students = {student1,student2,student3,student4,student5};
for(int i = 0 ; istudents.length; i){
double avgScore = students[i].testScore();
System.out.println(students[i].getStudentName() "学生的评测成绩为:"avgScore "分");
}
}
}
运行结果为:
张三学生的评测成绩为:69.66666666666667分
李四学生的评测成绩为:80.5分
王五学生的评测成绩为:78.0分
李六学生的评测成绩为:98.5分
朱漆学生的评测成绩为:60.03333333333333分
java中File源代码问题这是一个抽象类sunjava源代码,根据不同的操作系统会有不同的实现 。典型的windows和unix操作系统对文件的管理就不一样 。
getFileSystem()是一个本地方法sunjava源代码 , 看不到源代码 。
FileSystem类本来就不是提供给程序员使用的 。
反编译后的源代码如下:
package java.io;
// Referenced classes of package java.io:
//IOException, File
abstract class FileSystem
{
FileSystem()
{
}
public static native FileSystem getFileSystem();
public abstract char getSeparator();
public abstract char getPathSeparator();
public abstract String normalize(String s);
public abstract int prefixLength(String s);
public abstract String resolve(String s, String s1);
public abstract String getDefaultParent();
public abstract String fromURIPath(String s);
public abstract boolean isAbsolute(File file);
public abstract String resolve(File file);
public abstract String canonicalize(String s)
throws IOException;
public abstract int getBooleanAttributes(File file);
public abstract boolean checkAccess(File file, int i);
public abstract boolean setPermission(File file, int i, boolean flag, boolean flag1);
public abstract long getLastModifiedTime(File file);
public abstract long getLength(File file);
public abstract boolean createFileExclusively(String s)
throws IOException;
public abstract boolean delete(File file);
public abstract String[] list(File file);
public abstract boolean createDirectory(File file);
public abstract boolean rename(File file, File file1);
public abstract boolean setLastModifiedTime(File file, long l);
public abstract boolean setReadOnly(File file);
public abstract File[] listRoots();
public abstract long getSpace(File file, int i);
public abstract int compare(File file, File file1);
public abstract int hashCode(File file);
private static boolean getBooleanProperty(String s, boolean flag)
{
String s1 = System.getProperty(s);
if(s1 == null)
return flag;
return s1.equalsIgnoreCase("true");
}
public static final int BA_EXISTS = 1;
public static final int BA_REGULAR = 2;
public static final int BA_DIRECTORY = 4;
public static final int BA_HIDDEN = 8;
public static final int ACCESS_READ = 4;
public static final int ACCESS_WRITE = 2;
public static final int ACCESS_EXECUTE = 1;
public static final int SPACE_TOTAL = 0;
public static final int SPACE_FREE = 1;
public static final int SPACE_USABLE = 2;
static boolean useCanonCaches;
static boolean useCanonPrefixCache;
static
{
useCanonCaches = true;
useCanonPrefixCache = true;
useCanonCaches = getBooleanProperty("sun.io.useCanonCaches", useCanonCaches);
useCanonPrefixCache = getBooleanProperty("sun.io.useCanonPrefixCache", useCanonPrefixCache);
}
}
Java eclipse中无法查看源代码1.点 “window“- “Preferences”- “Java” - “Installed JRES”;
2.此时"Installed JRES"右边是列表窗格,列出了系统中的JRE 环境,选择你的JRE,然后点边上的“Edit...“,会出现一个窗口(Edit JRE) ;
3.选中rt.jar文件的这一项:“C:\Java\jdk1.5.0_04\jre\lib\rt.jar” 点 左边的“ ”号展开它(JDK实际安装路径以你的为准);
4.展开后,可以看到“Source Attachment:(none)”,点这一项,点右边的按钮“Source Attachment...“,选择你的JDK目录下的 “src.zip”文件;
5.一路点“ok”结束 。
JAVA开源是什么意思?标准C和C是不是开源的?一种语言有很多实现 。你说的是sun公司的java,其他公司也有java的版本,比如ibm,还有gnu的Java 。语言本身是一种标准,没有开源不开源的说法,除非大家有种默认的说法 。例如如果没有特指其他的java,java自然直sun公司的java 。
开源指的是语言的实现是开源的 。比如c,有turbo c,源代码不公开的,就不是开源的 。但是linux下默认的gcc是更符合c/c标准的一种实现,同时也是开源的 。而微软的各种c/C实现(visual c)就不是开源的 。
如果某种语言所有的实现都不是开源的 , 那它就不是开源的 。例如C#过去可以认为它不是开源的,因为仅有的实现visual c#不开源 。但c#是一种国际标准,如果有能力谁都可以做出自己的实现,像现在有了Mono project , 它是一个开源的c#实现,甚至可以在linux下用 。
强调的是 , 不是说只要公开就是开源,实际上还有其他版权的一些条款 , 你必须符合某种开源的版权 。还有不是说开源的你就可以随便用了,有很多开源产品都有类似“强盗”的条款:粗略地说,只要你用了它的代码,你的代码也必须开源 , 否则就侵权了 。如果做商用,必须仔细看你用的每一个开源库的版权声明,看是否要求你也开源 。
java中,如何查看sun标签库的类的源代码?sunjava源代码你说sunjava源代码的标签是什么
如果是开源的 那多半网上是可以查到
用java程序编写一个简单的登录界面怎么写?程序如下:
mport java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
@SuppressWarnings("serial")
public class MainFrame extends JFrame {
JLabel lbl1 = new JLabel("用户名:");
JLabel lbl2 = new JLabel("密码:");
JTextField txt = new JTextField("admin",20);
JPasswordField pwd = new JPasswordField(20);
JButton btn = new JButton("登录");
JPanel pnl = new JPanel();
private int error = 0;
public MainFrame(String title) throws HeadlessException {
super(title);
init();
}
private void init() {
this.setResizable(false);
pwd.setEchoChar('*');
pnl.add(lbl1);
pnl.add(txt);
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if ("admin".equal花憨羔窖薏忌割媳公颅s(new String(pwd.getPassword()))){
pnl.removeAll();
JLabel lbl3 = new JLabel();
ImageIcon icon = new ImageIcon(this.getClass().getResource("pic.jpg"));
lbl3.setIcon(icon);
pnl.add(lbl3);
}
else{
if(error3){
JOptionPane.showMessageDialog(null,"密码输入错误 , 请再试一次");
error;
}
else{
JOptionPane.showMessageDialog(null,"对不起,您不是合法用户");
txt.setEnabled(false);
pwd.setEnabled(false);
btn.setEnabled(false);
}
}
}
});
}
public static void main(String[] args) {
MainFrame frm = new MainFrame("测试");
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm.setBounds(100, 100, 300, 120);
frm.setVisible(true);
}
}
编程sunjava源代码的注意事项:
1、Java是一门面向对象编程语言 , 不仅吸收sunjava源代码了C语言的各种优点,还摒弃了C里难以理解的多继承、指针等概念,因此Java语言具有功能强大和简单易用两个特征 。Java语言作为静态面向对象编程语言的代表,极好地实现了面向对象理论,允许程序员以优雅的思维方式进行复杂的编程 。
2、 Java具有简单性、面向对象、分布式、健壮性、安全性、平台独立与可移植性、多线程、动态性等特点 。Java可以编写桌面应用程序、Web应用程序、分布式系统和嵌入式系统应用程序等 。
3、2006年11月13日,Java技术的发明者Sun公司宣布,将Java技术作为免费软件对外发布 。Sun公司正式发布的有关Java平台标准版的第一批源代码,以及Java迷你版的可执行源代码 。从2007年3月起,全世界所有的开发人员均可对Java源代码进行修改 。
【sunjava源代码 javascanner源码】sunjava源代码的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于javascanner源码、sunjava源代码的信息别忘了在本站进行查找喔 。

    推荐阅读