成都创新互联网站制作重庆分公司

java来源代码 java 来源

Java的来源

1.Java名字的由来,实际上是一个有趣的故事;

专注于为中小企业提供做网站、成都做网站服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业桥东免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千多家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

2.我们所见到的Java标志,总是一杯热咖啡,这杯热咖啡你很难与计算机编程联想到一起。这杯热咖啡、Java这个名字的由来,是Java创始人员团队中其中一名成员由于灵感想到的;

3.想起自己在Java岛(爪哇岛)上曾喝过一种美味的咖啡,于是这种计算机编程语言就命名为Java,与此同时它的标起来是我们最熟悉不过的一杯热咖啡。

延展阅读

Java的特点:

1.java的风格类似C++,从某种意义上讲,java是C++的一个变种;

2.java摒弃了C、C++中的容易引发错误和难以理解的指针,结构,以及内存管理等;

3.java提供了丰富的类库,很方便开发程序;

4.java是完全面向对象的语言,支持 继承,重载,多态等面向对象的特性;

5.C++是面向对象和面向过程的混合语言, C是纯面向过程的语言;

6.java是一种强类型的语言,比C/C++检查还要严格,java区分大小写字母;

7.java提供了自动垃圾回收机制gc,有效避免了C、C++的内存泄漏问题;

8.java禁止非法访问内存,因为java没有指针,内存的申请和释放;

9.跨平台,java的源代码编译成结构中立的中间格式,这种格式与机器无关,只要在安装有JVM(java虚拟机)的电脑上,都能运行这种与机器无关的中间文件;java一次编译,到处运行;

10.对于不同的操作系统,会有不同的java虚拟机,这也就决定了java的可移植性;

11.java支持多线程,简单理解,如果是单核CPU,那么会通过时间片轮转的方式,多线程执行程序,如果是多核CPU,那么就可以理解为,两个或多个线程同时运行。

java:哪里能看到JDK的源代码?

你安装JDK的目录下,有个src.zip文件,这个就是JDK源代码的java文件。

你可以解压来查看,但,最好是关联到IDE如 eclipse 中(不需解压),然后 CTRL + 点击就可以查看到源代码了。

如下图:

在MyEclipse中如何用ctrl查看java类的源代码

你现在是不是按下Ctrl点击的话就打开了一个Date.class的文件?里面只有属性和方法名,没有实现?

那是因为它找不到源代码,那个页面上有个按钮"Attach Source",点击,弹出打开对话框,选中你的源代码包(一个zip或jar文件)就好了,

如果你只有一个目录,里面是源代码(源文件必需是按照代码中package指定的路径存放的),你可以用winrar自己达成zip类型的包,

----------------------------------------

你说的显示不出来,是怎样一种情况?只显示class文件对吗?那就是你缺少源代码包,添加的方法请参照我昨天说的。

对你不明白的话的解释:

有时候我们下载来目录中有一个src文件夹,里面是源代码,而不是打包好的jar或zip文件。

src目录下的源代码是按照包结构存放的,比如a.java的第一行是package test;那么在src/test/就有一个a.java,选中src目录,右键“winrar-添加到压缩文件"默认是rar格式,选成zip,压缩就行了,压缩好后生成src.zip就可以被eclipse添加了

急需日历记事本JAVA源代码

import java.util.Calendar;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import java.util.Hashtable;

public class CalendarPad extends JFrame implements MouseListener

{

int year,month,day;

Hashtable hashtable;

File file;

JTextField showDay[];

JLabel title[];

Calendar 日历;

int 星期几;

NotePad notepad=null;

Month 负责改变月;

Year 负责改变年;

String 星期[]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};

JPanel leftPanel,rightPanel;

public CalendarPad(int year,int month,int day)

{

leftPanel=new JPanel();

JPanel leftCenter=new JPanel();

JPanel leftNorth=new JPanel();

leftCenter.setLayout(new GridLayout(7,7));

rightPanel=new JPanel();

this.year=year;

this.month=month;

this.day=day;

负责改变年=new Year(this);

负责改变年.setYear(year);

负责改变月=new Month(this);

负责改变月.setMonth(month);

title=new JLabel[7];

showDay=new JTextField[42];

for(int j=0;j7;j++)

{

title[j]=new JLabel();

title[j].setText(星期[j]);

title[j].setBorder(BorderFactory.createRaisedBevelBorder());

leftCenter.add(title[j]);

}

title[0].setForeground(Color.red);

title[6].setForeground(Color.blue);

for(int i=0;i42;i++)

{

showDay[i]=new JTextField();

showDay[i].addMouseListener(this);

showDay[i].setEditable(false);

leftCenter.add(showDay[i]);

}

日历=Calendar.getInstance();

Box box=Box.createHorizontalBox();

box.add(负责改变年);

box.add(负责改变月);

leftNorth.add(box);

leftPanel.setLayout(new BorderLayout());

leftPanel.add(leftNorth,BorderLayout.NORTH);

leftPanel.add(leftCenter,BorderLayout.CENTER);

leftPanel.add(new Label("请在年份输入框输入所查年份(负数表示公元前),并回车确定"),

BorderLayout.SOUTH) ;

leftPanel.validate();

Container con=getContentPane();

JSplitPane split=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,

leftPanel,rightPanel);

con.add(split,BorderLayout.CENTER);

con.validate();

hashtable=new Hashtable();

file=new File("日历记事本.txt");

if(!file.exists())

{

try{

FileOutputStream out=new FileOutputStream(file);

ObjectOutputStream objectOut=new ObjectOutputStream(out);

objectOut.writeObject(hashtable);

objectOut.close();

out.close();

}

catch(IOException e)

{

}

}

notepad=new NotePad(this);

rightPanel.add(notepad);

设置日历牌(year,month);

addWindowListener(new WindowAdapter()

{ public void windowClosing(WindowEvent e)

{

System.exit(0);

}

});

setVisible(true);

setBounds(100,50,524,285);

validate();

}

public void 设置日历牌(int year,int month)

{

日历.set(year,month-1,1);

星期几=日历.get(Calendar.DAY_OF_WEEK)-1;

if(month==1||month==2||month==3||month==5||month==7

||month==8||month==10||month==12)

{

排列号码(星期几,31);

}

else if(month==4||month==6||month==9||month==11)

{

排列号码(星期几,30);

}

else if(month==2)

{

if((year%4==0year%100!=0)||(year%400==0))

{

排列号码(星期几,29);

}

else

{

排列号码(星期几,28);

}

}

}

public void 排列号码(int 星期几,int 月天数)

{

for(int i=星期几,n=1;i星期几+月天数;i++)

{

showDay[i].setText(""+n);

if(n==day)

{

showDay[i].setForeground(Color.green);

showDay[i].setFont(new Font("TimesRoman",Font.BOLD,20));

}

else

{

showDay[i].setFont(new Font("TimesRoman",Font.BOLD,12));

showDay[i].setForeground(Color.black);

}

if(i%7==6)

{

showDay[i].setForeground(Color.blue);

}

if(i%7==0)

{

showDay[i].setForeground(Color.red);

}

n++;

}

for(int i=0;i星期几;i++)

{

showDay[i].setText("");

}

for(int i=星期几+月天数;i42;i++)

{

showDay[i].setText("");

}

}

public int getYear()

{

return year;

}

public void setYear(int y)

{

year=y;

notepad.setYear(year);

}

public int getMonth()

{

return month;

}

public void setMonth(int m)

{

month=m;

notepad.setMonth(month);

}

public int getDay()

{

return day;

}

public void setDay(int d)

{

day=d;

notepad.setDay(day);

}

public Hashtable getHashtable()

{

return hashtable;

}

public File getFile()

{

return file;

}

public void mousePressed(MouseEvent e)

{

JTextField source=(JTextField)e.getSource();

try{

day=Integer.parseInt(source.getText());

notepad.setDay(day);

notepad.设置信息条(year,month,day);

notepad.设置文本区(null);

notepad.获取日志内容(year,month,day);

}

catch(Exception ee)

{

}

}

public void mouseClicked(MouseEvent e)

{

}

public void mouseReleased(MouseEvent e)

{

}

public void mouseEntered(MouseEvent e)

{

}

public void mouseExited(MouseEvent e)

{

}

public static void main(String args[])

{

Calendar calendar=Calendar.getInstance();

int y=calendar.get(Calendar.YEAR);

int m=calendar.get(Calendar.MONTH)+1;

int d=calendar.get(Calendar.DAY_OF_MONTH);

new CalendarPad(y,m,d);

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class Month extends Box implements ActionListener

{

int month;

JTextField showMonth=null;

JButton 下月,上月;

CalendarPad 日历;

public Month(CalendarPad 日历)

{

super(BoxLayout.X_AXIS);

this.日历=日历;

showMonth=new JTextField(2);

month=日历.getMonth();

showMonth.setEditable(false);

showMonth.setForeground(Color.blue);

showMonth.setFont(new Font("TimesRomn",Font.BOLD,16));

下月=new JButton("下月");

上月=new JButton("上月");

add(上月);

add(showMonth);

add(下月);

上月.addActionListener(this);

下月.addActionListener(this);

showMonth.setText(""+month);

}

public void setMonth(int month)

{

if(month=12month=1)

{

this.month=month;

}

else

{

this.month=1;

}

showMonth.setText(""+month);

}

public int getMonth()

{

return month;

}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==上月)

{

if(month=2)

{

month=month-1;

日历.setMonth(month);

日历.设置日历牌(日历.getYear(),month);

}

else if(month==1)

{

month=12;

日历.setMonth(month);

日历.设置日历牌(日历.getYear(),month);

}

showMonth.setText(""+month);

}

else if(e.getSource()==下月)

{

if(month12)

{

month=month+1;

日历.setMonth(month);

日历.设置日历牌(日历.getYear(),month);

}

else if(month==12)

{

month=1;

日历.setMonth(month);

日历.设置日历牌(日历.getYear(),month);

}

showMonth.setText(""+month);

}

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import java.awt.*;

import java.awt.event.*;

import java.util.*;

import javax.swing.*;

import javax.swing.event.*;

import java.io.*;

public class NotePad extends JPanel implements ActionListener

{

JTextArea text;

JButton 保存日志,删除日志;

Hashtable table;

JLabel 信息条;

int year,month,day;

File file;

CalendarPad calendar;

public NotePad(CalendarPad calendar)

{

this.calendar=calendar;

year=calendar.getYear();

month=calendar.getMonth();

day=calendar.getDay();;

table=calendar.getHashtable();

file=calendar.getFile();

信息条=new JLabel(""+year+"年"+month+"月"+day+"日",JLabel.CENTER);

信息条.setFont(new Font("TimesRoman",Font.BOLD,16));

信息条.setForeground(Color.blue);

text=new JTextArea(10,10);

保存日志=new JButton("保存日志") ;

删除日志=new JButton("删除日志") ;

保存日志.addActionListener(this);

删除日志.addActionListener(this);

setLayout(new BorderLayout());

JPanel pSouth=new JPanel();

add(信息条,BorderLayout.NORTH);

pSouth.add(保存日志);

pSouth.add(删除日志);

add(pSouth,BorderLayout.SOUTH);

add(new JScrollPane(text),BorderLayout.CENTER);

}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==保存日志)

{

保存日志(year,month,day);

}

else if(e.getSource()==删除日志)

{

删除日志(year,month,day);

}

}

public void setYear(int year)

{

this.year=year;

}

public int getYear()

{

return year;

}

public void setMonth(int month)

{

this.month=month;

}

public int getMonth()

{

return month;

}

public void setDay(int day)

{

this.day=day;

}

public int getDay()

{

return day;

}

public void 设置信息条(int year,int month,int day)

{

信息条.setText(""+year+"年"+month+"月"+day+"日");

}

public void 设置文本区(String s)

{

text.setText(s);

}

public void 获取日志内容(int year,int month,int day)

{

String key=""+year+""+month+""+day;

try

{

FileInputStream inOne=new FileInputStream(file);

ObjectInputStream inTwo=new ObjectInputStream(inOne);

table=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

}

catch(Exception ee)

{

}

if(table.containsKey(key))

{

String m=""+year+"年"+month+"月"+day+"这一天有日志记载,想看吗?";

int ok=JOptionPane.showConfirmDialog(this,m,"询问",JOptionPane.YES_NO_OPTION,

JOptionPane.QUESTION_MESSAGE);

if(ok==JOptionPane.YES_OPTION)

{

text.setText((String)table.get(key));

}

else

{

text.setText("");

}

}

else

{

text.setText("无记录");

}

}

public void 保存日志(int year,int month,int day)

{

String 日志内容=text.getText();

String key=""+year+""+month+""+day;

String m=""+year+"年"+month+"月"+day+"保存日志吗?";

int ok=JOptionPane.showConfirmDialog(this,m,"询问",JOptionPane.YES_NO_OPTION,

JOptionPane.QUESTION_MESSAGE);

if(ok==JOptionPane.YES_OPTION)

{

try

{

FileInputStream inOne=new FileInputStream(file);

ObjectInputStream inTwo=new ObjectInputStream(inOne);

table=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

table.put(key,日志内容);

FileOutputStream out=new FileOutputStream(file);

ObjectOutputStream objectOut=new ObjectOutputStream(out);

objectOut.writeObject(table);

objectOut.close();

out.close();

}

catch(Exception ee)

{

}

}

}

public void 删除日志(int year,int month,int day)

{

String key=""+year+""+month+""+day;

if(table.containsKey(key))

{

String m="删除"+year+"年"+month+"月"+day+"日的日志吗?";

int ok=JOptionPane.showConfirmDialog(this,m,"询问",JOptionPane.YES_NO_OPTION,

JOptionPane.QUESTION_MESSAGE);

if(ok==JOptionPane.YES_OPTION)

{

try

{

FileInputStream inOne=new FileInputStream(file);

ObjectInputStream inTwo=new ObjectInputStream(inOne);

table=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

table.remove(key);

FileOutputStream out=new FileOutputStream(file);

ObjectOutputStream objectOut=new ObjectOutputStream(out);

objectOut.writeObject(table);

objectOut.close();

out.close();

text.setText(null);

}

catch(Exception ee)

{

}

}

}

else

{

String m=""+year+"年"+month+"月"+day+"无日志记录";

JOptionPane.showMessageDialog(this,m,"提示",JOptionPane.WARNING_MESSAGE);

}

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class Year extends Box implements ActionListener

{

int year;

JTextField showYear=null;

JButton 明年,去年;

CalendarPad 日历;

public Year(CalendarPad 日历)

{

super(BoxLayout.X_AXIS);

showYear=new JTextField(4);

showYear.setForeground(Color.blue);

showYear.setFont(new Font("TimesRomn",Font.BOLD,14));

this.日历=日历;

year=日历.getYear();

明年=new JButton("下年");

去年=new JButton("上年");

add(去年);

add(showYear);

add(明年);

showYear.addActionListener(this);

去年.addActionListener(this);

明年.addActionListener(this);

}

public void setYear(int year)

{

this.year=year;

showYear.setText(""+year);

}

public int getYear()

{

return year;

}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==去年)

{

year=year-1;

showYear.setText(""+year);

日历.setYear(year);

日历.设置日历牌(year,日历.getMonth());

}

else if(e.getSource()==明年)

{

year=year+1;

showYear.setText(""+year);

日历.setYear(year);

日历.设置日历牌(year,日历.getMonth());

}

else if(e.getSource()==showYear)

{

try

{

year=Integer.parseInt(showYear.getText());

showYear.setText(""+year);

日历.setYear(year);

日历.设置日历牌(year,日历.getMonth());

}

catch(NumberFormatException ee)

{

showYear.setText(""+year);

日历.setYear(year);

日历.设置日历牌(year,日历.getMonth());

}

}

}

}

希望能帮到你,以上分为4个类。。分割线以标注了


新闻标题:java来源代码 java 来源
转载注明:http://cxhlcq.com/article/hpieoi.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部