java是跨平臺的,所以不可能弄成。exe那樣給你看
公司主營業務:網站建設、成都做網站、移動網站開發等業務。幫助企業客戶真正實現互聯網宣傳,提高企業的競爭能力。成都創新互聯公司是一支青春激揚、勤奮敬業、活力青春激揚、勤奮敬業、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴謹、自律”為核心的企業文化,感謝他們對我們的高要求,感謝他們從不同領域給我們帶來的挑戰,讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。成都創新互聯公司推出芙蓉免費做網站回饋大家。
java首先要被編譯成.CLASS,然后你在執行的時候解釋成你可以看的具體界面
要想看界面 ,如果是JSP的就要配置tomcat服務器
如果是小程序就是javac 編譯么
如果是大項目,用集成開發工具eclipse看(類似你的VC++)
下面是一個可能的Java源代碼,它包含了一個接口(Shape)和五個類(Circle, Rectangle, Triangle, Square 和 Main)。它的功能是計算不同形狀的面積和周長。
//定義一個接口Shape,有兩個抽象方法:getArea()和getPerimeter()interface Shape { double getArea(); double getPerimeter();
}//定義一個類Circle,實現Shape接口class Circle implements Shape { //定義一個私有屬性radius,表示圓的半徑
private double radius; //定義一個公有構造方法,用于初始化radius
public Circle(double radius) { this.radius = radius;
} //實現getArea()方法,返回圓的面積
public double getArea() { return Math.PI * radius * radius;
} //實現getPerimeter()方法,返回圓的周長
public double getPerimeter() { return Math.PI * radius * 2;
}
}//定義一個類Rectangle,實現Shape接口class Rectangle implements Shape { //定義兩個私有屬性width和height,表示矩形的寬度和高度
private double width; private double height; //定義一個公有構造方法,用于初始化width和height
public Rectangle(double width, double height) { this.width = width; this.height = height;
} //實現getArea()方法,返回矩形的面積
public double getArea() { return width * height;
} //實現getPerimeter()方法,返回矩形的周長
public double getPerimeter() { return (width + height) *2;
}
}//定義一個類Triangle,實現Shape接口class Triangle implements Shape { //定義三個私有屬性a,b,c表示三角形的三條邊長
private double a; private double b; private double c; //定義一個公有構造方法,用于初始化a,b,c,并檢查是否滿足三角形條件(任意兩邊之和大于第三邊)
public Triangle(double a, double b, double c) throws Exception{ if (a + b c a + c b b + c a) {
this.a = a; this.b = b;
this.c = c;
} else {
throw new Exception("Invalid triangle");
}
} //實現getArea()方法,返回三角形的面積(使用海倫公式)
public double getArea() { //計算半周長p
double p = (a + b + c) /2; //計算并返回面積s(使用Math.sqrt()函數求平方根)
return Math.sqrt(p * (p - a) * (p - b) * (p - c));
} //實現getPerimeter()方法,返回三角形的周長
public double getPerimeter(){ return a + b + c;
}
}//定義一個類Square,繼承Rectangle類,并重寫構造方法和toString()方法class Square extends Rectangle { //重寫構造方法,在調用父類構造方法時傳入相同的參數side作為width和height
public Square(double side){ super(side, side);
} //重寫toString()方法,在原來基礎上加上"Square:"前綴,并只顯示side屬性而不顯示width和height屬性(使用String.format()函數格式化字符串)
@Override
public String toString(){ return String.format("Square: side=%.2f", super.width); /* 或者直接使用super.getPerimeter()/4作為side */
/* return String.format("Square: side=%.2f", super.getPerimeter()/4); */
/* 注意:不能直接訪問super.side屬性,
package com.test01;
import java.util.Scanner;
public class oop5 { public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// int x = 9;
// int y = 1;
int x = sc.nextInt();
int y = sc.nextInt();
int z;
z = add(x, y);
System.out.println("x的值為:" + x);
System.out.println("y的值為:" + y);
System.out.println("二者之和為:" + z);
}
/** 四種小算法 */
// 加法運算
public static int add(int a, int b) {
int c;
c = a + b;
return c;
}
// 減法運算
public static int jian(int d, int v) {
int m;
m = d - v;
return m;
}
// 乘積運算
public static int addAdd(int q, int w) {
int e;
e = q * w;
return e;
}
// 除法運算
public static int chu(int p, int k) {
int f;
f = p / k;
return f;
}
}
網頁標題:java寫的頒獎源代碼 java年會抽獎代碼
網頁地址:http://www.2m8n56k.cn/article40/ddosoeo.html
成都網站建設公司_創新互聯,為您提供Google、品牌網站設計、網站改版、靜態網站、關鍵詞優化、
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:[email protected]。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯