「java大神号」Java大神
本篇文章给大家谈谈java大神号,以及Java大神对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
Java大神 谢谢!
package tex1;
import java.util.Date;
public class exam1 {
public static void main(String[] args) {
MyThread myThread1 = new MyThread();
MyThread myThread2 = new MyThread();
myThread1.setName("Fast Thread");
myThread2.setName("Slow Thread");
myThread1.setTimes(1000);
myThread2.setTimes(3000);
Thread thread1 = new Thread(myThread1);
Thread thread2 = new Thread(myThread2);
thread1.start();
thread2.start();
}
}
class MyThread implements Runnable {
private long times;
private String name;
public void setName(String name) {
this.name = name;
}
public void setTimes(long times) {
this.times = times;
}
@Override
public void run() {
for(int i = 0; i10 ;i++){
Date nowTime = new Date();
System.out.println(name + ":" + nowTime);
try {
Thread.sleep(times);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
输出结果是:
请采纳!谢谢~
求Java大神解释
你是想问的属性相等还是值相等? 你这段程序肯定是截取了一部分吧, 如果A 没有私有成员变量,那么值会相等,但是p0 和p1 是两个不同对象,他们的内存地址就不可能相等,那么对象就不相等。。
急求Java编程大神!!!初学者真的不会做!!求代码!
邮箱给我,给你发一下我编的:
package javalotto;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
/**
*
* @author Angel
*/
public class JavaLotto {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("Please enter a Number");
Scanner s = new Scanner(System.in);
final int lotto = s.nextInt();
// final int lotto = random();
final int randomnum = random();
// final int randomnum = lotto;
System.out.println(randomnum+" "+lotto);
if(lotto999){
System.out.println("wrong number please try again!");
}else{
if(lotto==randomnum){
System.out.println("you win 10000!");
showdate();
}
else {if(Checkthree(lotto,randomnum)){
System.out.println("you win 3000!");
showdate();
}
if(Checkone(lotto,randomnum)){
System.out.println("you win 1000!");
showdate();
}
}
// System.out.println(randomnum);
}
// TODO code application logic here
}
public static int random(){
double num = Math.random()*999;
int finalnum = (int)num;
return finalnum;
}
public static void showdate(){
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
System.out.println(dateFormat.format(date));
}
public static boolean Checkthree(int a,int b){
boolean flag=false;
int[] first = {0,0,0};
int[] secd = {0,0,0};
int account = 0;
for(int i = 0; i3;i++){
int temp =(int)java.lang.Math.pow(10, 2-i);
int temp1 = a/temp;
first[i]=temp1;
a-=a%temp;
}
for(int i = 0; i3;i++){
int temp = (int)java.lang.Math.pow(10, 2-i);
secd[i]=b/temp;
b-=b%temp;
}
for(int i = 0;i3;i++){
for(int j = 0;j3;j++){
if(first[i]==secd[j]){
account ++;
break;
}
}
}
if(account == 3)
flag = true;
return flag;
}
public static boolean Checkone(int a,int b){
boolean flag=false;
int[] first = {0,0,0};
int[] secd = {0,0,0};
int account = 0;
for(int i = 0; i3;i++){
int temp = (int)java.lang.Math.pow(10, 2-i);
first[i]=a/temp;
a-=a%temp;
}
for(int i = 0; i3;i++){
int temp = (int)java.lang.Math.pow(10, 2-i);
secd[i]=b/temp;
b-=b%temp;
}
for(int i = 0;i3;i++){
for(int j = 0;j3;j++){
if(first[i]==secd[j]){
account ++;
break;
}
}
}
if(account 0 account3)
flag = true;
return flag;
}
}
java 大神呢
11题选C,静态方法覆盖必须覆盖为静态方法;
12题选B,覆盖方法返回值、方法名、参数列表都必须相同。
求教Java大神!!
首先安装JDK
再在 我的电脑-属性-高级系统设置-环境变量中设置变量
path变量如果你没有就新建一个
也可以在系统变量中的path路径中添加,就不用去用户变量去添加了
区别在于用户变量添加的电脑换一个用户登录之前的用户设置的变量是不存在的,而系统变量是不变的。
在dos中使用
java -version
求java大神,求解
排序算法可以参考:
java排序之冒泡排序网页链接
、这个问题主要是在排序的基础上使用了对象并且对象的属性是两个需要同时对比两个条件才能得到最终的结果。
第一种情况:
1.1 首先按照要求编写实体类。
import java.util.Comparator;
public class Column implements Comparable {
private int radius;
private int h;
public Column(){};
public Column(int radius,int h){
this.radius = radius;
this.h = h;
};
@Override
public String toString() {
return "Column{" +
"radius=" + radius +
", h=" + h +
'}';
}
@Override
public int compareTo(Object o) {
return 0;
}
public int getRadius() {
return radius;
}
public void setRadius(int radius) {
this.radius = radius;
}
public int getH() {
return h;
}
public void setH(int h) {
this.h = h;
}
}
1.2 编写测试类
我依然使用的是基础的冒泡排序。
public class ColumnTest {
public static void main(String[] args) {
Column co1 = new Column(5,3);
Column co2 = new Column(2,4);
Column co3 = new Column(4,3);
Column co4 = new Column(2,3);
Column co5 = new Column(4,6);
Column[] arry = {co1,co2,co3,co4,co5};
Column cnj;
//使用冒泡排序
for (int i = 0; i arry.length -1 ; i++) {
for (int j = 0; j arry.length-1; j++) {
cnj = arry[j];
if ( arry[j+1].getRadius() cnj.getRadius() || (cnj.getRadius()==arry[j+1].getRadius() arry[j+1].getH() cnj.getH())){
arry[j] = arry[j+1];
arry[j+1] = cnj;
}
}
}
//打印输出
for (int i = 0; i arry.length; i++) {
System.out.print("("+arry[i].getRadius()+","+arry[i].getH()+") ");
}
}
}
第二种要求使用double数据类型改一下类型就可以了
1.1 实体类如下
import java.util.Comparator;
public class Column implements Comparable {
private double radius;
private double h;
public Column(){};
public Column(double radius,double h){
this.radius = radius;
this.h = h;
};
@Override
public String toString() {
return "Column{" +
"radius=" + radius +
", h=" + h +
'}';
}
@Override
public int compareTo(Object o) {
return 0;
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public double getH() {
return h;
}
public void setH(double h) {
this.h = h;
}
}
1.2 测试类原样不变直接使用。
关于java大神号和Java大神的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
发布于:2022-12-07,除非注明,否则均为
原创文章,转载请注明出处。