快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

经典的java程序代码 经典的java程序代码是什么

一个简单的Java程序代码?

package com.zpp;public class Charge {

站在用户的角度思考问题,与客户深入沟通,找到唐山网站设计与唐山网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站制作、做网站、企业官网、英文网站、手机端网站、网站推广、域名注册虚拟主机、企业邮箱。业务覆盖唐山地区。

public static void main(String [] args) {

if(args.length ==0) {

System.out.println("parameter error!");

System.out.println("java com.zpp.Charge [int]");

return;

}

int min = Integer.parseInt(args[0]);

double money = 0.0;

if (min = 0) {

money =0.0;

System.out.println("not money");

} else if (min = 60) {

money = 2.0;

} else {

money = 2.0 + (min - 60) * 0.01;

}

System.out.println("please pay: " + money);

}

} 编译:javac -d . Charge.java运行:java com.zpp.Charge 111

JAVA程序几个经典的程序

import java.applet.*;

import java.awt.*;

import java.awt.event.*;

public class ResponseToMouse extends Applet implements ActionListener,MouseListener,MouseMotionListener

{

int xPos,yPos,k=0;

Button btnDraw,btnClean,btnErase;

public void init()

{

btnDraw = new Button("画图");

btnClean = new Button("清屏");

btnErase = new Button("擦除");

add(btnDraw);

add(btnClean);

add(btnErase);

btnDraw.addActionListener(this);

btnClean.addActionListener(this);

btnErase.addActionListener(this);

addMouseListener(this);

addMouseMotionListener(this);

}

public void paint(Graphics g)

{

if(k==1)

{

g.setColor(Color.red);

g.fillOval(xPos-5,yPos-5,10,10);

}

if(k==2)

{

super.update(g);

}

if(k==3)

{

g.setColor(Color.white);

g.fillOval(xPos-5,yPos-5,10,10);

}

}

public void actionPerformed(ActionEvent e){

if (e.getSource()==btnDraw)

k=1;

if(e.getSource()==btnClean){

k=2;

repaint();

}

if(e.getSource()==btnErase)

k=3;

}

public void mouseClicked(MouseEvent e)

{

}

public void mousePressed(MouseEvent e)

{

showStatus("鼠标键按下");

}

public void mouseReleased(MouseEvent e)

{

showStatus("鼠标键释放");

}

public void mouseEntered(MouseEvent e)

{

showStatus("鼠标进入");

}

public void mouseExited(MouseEvent e)

{

showStatus("鼠标移出");

}

public void mouseDragged(MouseEvent e)

{

xPos=e.getX();

yPos=e.getY();

repaint();

}

public void mouseMoved(MouseEvent e)

{

showStatus("鼠标移动");

}

public void update(Graphics g){

paint(g);

}

}

给段最简单的java代码 让我新手看一下

最简单的java代码肯定就是这个了,如下:

public class MyFirstApp

{

public static void main(String[] args)

{

System.out.print("Hello world");

}

}

“hello world”就是应该是所有学java的新手看的第一个代码了。如果是零基础的新手朋友们可以来我们的java实验班试听,有免费的试听课程帮助学习java必备基础知识,有助教老师为零基础的人提供个人学习方案,学习完成后有考评团进行专业测试,帮助测评学员是否适合继续学习java,15天内免费帮助来报名体验实验班的新手快速入门java,更好的学习java!

求一个java程序代码

package Test1;

import java.time.LocalDateTime;

import java.time.Month;

import java.util.IntSummaryStatistics;

import java.util.Scanner;

import java.util.Vector;

public class D {

static String s1 = "";

public static void main(String[] args) {

int day = LocalDateTime.now().getDayOfMonth();

Month month = LocalDateTime.now().getMonth();

int i = 1, i1 = 0;

VectorInteger vector=new Vector();

Scanner scanner = new Scanner(System.in);

while (i day + 1) {

System.out.println("请输入" + month + "月" + i + "日走的步数");

try {

i1 = scanner.nextInt();

} catch (Exception e) {

// TODO: handle exception

System.out.println("输入错误,请重新输入");

continue;

}

vector.add(i1);

i++;

}

scanner.close();

IntSummaryStatistics intSummaryStatistics=vector.stream().mapToInt(x-x).summaryStatistics();

int i2=intSummaryStatistics.getMax();

int i3=vector.indexOf(i2);

System.out.println(month+"月走的步数最多的日期为: "+(i3+1)+"号");

System.out.println("最多的步数为: "+i2);

}

}

求java经典小程序代码

代码如下:

public class HelloWorld {

public static void main(String []args) {

int a = 3, b = 7 ;

 System.out.println("Hello World!");

}

public static int f(int a, int b){

return a*a + a*b + b*b;

}

}

结果如下:

java线程的经典代码

package threadgroup;

class ThreadDemo3 extends Thread {

private String name;

private int delay;

public ThreadDemo3(String sname, int i_delay) {

name = sname;

delay = i_delay;

}

public void run() {

try {

sleep(delay);

} catch (InterruptedException e) {

}

System.out.println("多线程测试!\n" + name + "\n" + delay);

}

}

public class testMyThread {

public static void main(String[] args) {

ThreadDemo3 th1,th2,th3;

th1 = new ThreadDemo3("线程1", (int) (Math.random() * 900));

th2 = new ThreadDemo3("线程2", (int) (Math.random() * 900));

th3 = new ThreadDemo3("线程3", (int) (Math.random() * 900));

th1.start();

th2.start();

th3.start();

}

}

package threadgroup;

public class threadDemo {

public static void main(String[] args) {

Thread t = Thread.currentThread();

t.setName("你好吗?");

System.out.println("正在进行的Thread是:" + t);

try {

for (int i = 0; i 5; i++) {

System.out.println("我不叫穆继超" + i);

Thread.sleep(3000);

}

} catch (Exception e) {

// TODO: handle exception

System.out.println("Thread has wrong" + e.getMessage());

}

}

}

package threadgroup;

public class threadDemo2 implements Runnable {

public threadDemo2() {

Thread t1 = Thread.currentThread();

t1.setName("第一个主进程");

System.out.println("正在运行" + t1);

Thread t2 = new Thread(this, "");

System.out.println("在创建一个进程");

t2.start();

try {

System.out.println("使他进入第一个睡眠状态");

Thread.sleep(2000);

} catch (InterruptedException e) {

System.out.println("Thread has wrong" + e.getMessage());

}

System.out.println("退出第一个进程");

}

public void run() {

try {

for (int i = 0; i 5; i++) {

System.out.println("进程" + i);

Thread.sleep(3000);

}

} catch (InterruptedException e) {

// TODO: handle exception

System.out.println("Thread has wrong" + e.getMessage());

}

System.out.println("退出第二个进程");

}

public static void main(String[] args) {

new threadDemo2();

}

}


新闻名称:经典的java程序代码 经典的java程序代码是什么
转载注明:http://6mz.cn/article/doscdjh.html

其他资讯