首页技术简单的源代码(最简单的源代码)

简单的源代码(最简单的源代码)

编程之家2026-06-19651次浏览

大家好,简单的源代码相信很多的网友都不是很明白,包括最简单的源代码也是一样,不过没有关系,接下来就来为大家分享关于简单的源代码和最简单的源代码的一些知识点,大家可以关注收藏,免得下次来找不到哦,下面我们开始吧!

简单的源代码(最简单的源代码)

求编写一个超级简单的Java的程序源代码

你好

很高兴能够回答你的问题。

我帮你实现了一个复数类,并且可以执行复数的加减,乘除你再写两个方法就可以了:

代码如下:

public class complie{

int i,j;

简单的源代码(最简单的源代码)

public complie(int i,int j)//构建一个复数类

{

this.i=i;

this.j=j;

}

complie add(complie c)//复数加法

简单的源代码(最简单的源代码)

{

int l,k;

l=c.i+i;

k=c.j+j;

return(new complie(l,k));

}

complie cut(complie c)//复数减法

{

int l,k;

l=i-c.i;

k=j-c.j;

return(new complie(l,k));

}

void ToString()//将复数输出

{

System.out.println("复数为:"+i+"+"+j+"i");

}

public static void main(String[] args)

{

complie a=new complie(4,5);

complie b=new complie(2,3);

System.out.println("构造的复数类为:");

a.ToString();

b.ToString();

System.out.println("运算复数a+b=:");

a.add(b).ToString();

System.out.println("运算复数a-b=:");

a.cut(b).ToString();

}

}

运行结果:

--------------------Configuration:<Default>--------------------

构造的复数类为:

复数为:4+5i

复数为:2+3i

运算复数a+b=:

复数为:6+8i

运算复数a-b=:

复数为:2+2i

Process completed.

程序我已经调试通过了的。

希望能帮到你,同时希望你能采纳我的答案,谢谢!

急求一段简单的java源代码(用户名、密码操作界面)

下面的程序可以直接通过编译运行,自己寻找要用到的代码段。

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.FocusEvent;

import java.awt.event.FocusListener;

import java.io.File;

import java.io.IOException;

import java.io.RandomAccessFile;

import javax.swing.BoxLayout;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JPasswordField;

import javax.swing.JTextField;

public class UserLogin extends JPanel implements ActionListener{

JTextField userjt=null;//用户输入框

JPasswordField pwdjt=null;

JTextField sysUserjt=null;//系统显示用户名输入框

JTextField sysPwdjt=null;

public UserLogin(){

super(new GridLayout(1,2));

JPanel userPanel=new JPanel();//用户界面,左边

userPanel.setLayout(new BoxLayout(userPanel,BoxLayout.Y_AXIS));

this.add(userPanel);

JPanel userUpPanel=new JPanel();//用户界面上半部分

userPanel.add(userUpPanel);

JPanel userDownPanel=new JPanel();//用户界面下半部分

userPanel.add(userDownPanel);

JPanel sysPanel=new JPanel();//系统界面,右边

sysPanel.setLayout(new BoxLayout(sysPanel,BoxLayout.Y_AXIS));

this.add(sysPanel);

JPanel sysUserPanel=new JPanel();//系统界面上半部分

sysPanel.add(sysUserPanel);

JPanel sysPwdPanel=new JPanel();//系统界面下半部分

sysPanel.add(sysPwdPanel);

userjt=new JTextField(5);

userjt.setText("用户名");

userUpPanel.add(userjt);

pwdjt=new JPasswordField(5);

pwdjt.setText("密码");

pwdjt.setEchoChar('\0');

userDownPanel.add(pwdjt);

JLabel sysUserjl=new JLabel("用户名为:");

sysUserPanel.add(sysUserjl);

sysUserjt=new JTextField(5);

sysUserPanel.add(sysUserjt);

JLabel sysPwdjl=new JLabel("密码为:");

sysPwdPanel.add(sysPwdjl);

sysPwdjt=new JTextField(5);

sysPwdPanel.add(sysPwdjt);

userjt.addActionListener(this);

pwdjt.addActionListener(this);

userjt.addFocusListener(new FocusListener(){

public void focusGained(FocusEvent e){

if(userjt.getText().equals("用户名"))

userjt.setText("");

}

public void focusLost(FocusEvent e){

if(userjt.getText().equals(""))

userjt.setText("用户名");

}});

pwdjt.addFocusListener(new FocusListener(){

public void focusGained(FocusEvent e){

if(new String(pwdjt.getPassword()).equals("密码")){

pwdjt.setText("");

pwdjt.setEchoChar('*');

}

}

public void focusLost(FocusEvent e){

if(new String(pwdjt.getPassword()).equals("")){

pwdjt.setText("密码");

pwdjt.setEchoChar('\0');

}

}});

}

public void actionPerformed(ActionEvent e){

if(e.getSource().equals(userjt)){

pwdjt.requestFocus();

}else{

if(new String(pwdjt.getPassword()).equals("")||userjt.getText().equals("")||userjt.getText().equals("用户名")) return;

sysUserjt.setText(userjt.getText());

sysPwdjt.setText(new String(pwdjt.getPassword()));

try{

writetoFile();

} catch(IOException e1){

System.out.println("写入文件发生异常!");

e1.printStackTrace();

}

}

}

private void writetoFile() throws IOException{

File f=new File("User_Psd.txt");

// if(!f.exists()) f.createNewFile();

RandomAccessFile accessFile=new RandomAccessFile(f,"rw");

accessFile.seek(accessFile.length());

accessFile.write(("user:"+userjt.getText()+"\r\npassword:"+new String(pwdjt.getPassword())+"\r\n\r\n").getBytes());

}

public static void main(String args[]){

JFrame jf=new JFrame("用户登陆模块测试");

jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);

jf.add(new UserLogin());

jf.setBounds(400,300,280,150);

jf.setVisible(true);

}

}

简单的html个人主页源代码

个人html主页站点所提供的多半是纯文字或图片等静态信息,而就站点的性质来说,则以教学或特定主题(如历史、古典文学、电玩、旅游记录等)的站台为多数。

你可以通过千站素材下载html网页源码,制作你的"个人主页",用于展示你自己的个性,将自己喜欢的东西放在"个人主页"上,让大家都可以来欣赏。

好了,文章到这里就结束啦,如果本次分享的简单的源代码和最简单的源代码问题对您有所帮助,还望关注下本站哦!

html下拉框选择怎么设置的 html基础语法input在python中的用法 int(input())怎么用