公告版位
需要找什麼嗎? 左邊分類或許可以幫助你...

目前分類:[程式語言] Java (91)

瀏覽方式: 標題列表 簡短摘要

import java.net.*;

String ip = InetAddress.getLocalHost().getHostAddress() ;


黃彥霖 發表在 痞客邦 留言(0) 人氣()

指向一個不存在的圖片將可隱藏滑鼠

setCursor(this.getToolkit().cr
eateCustomCursor(new ImageIcon("").getImage(),new Point(16, 16),""));


黃彥霖 發表在 痞客邦 留言(0) 人氣()

//-- HashSet----------------------------------------

//無順序,但是加入相同物件的資料 會被過濾掉

import java.util.*;
public class SetTest{
    public static void main(String[] args){
        HashSet hs=new HashSet();
        hs.add(8);
        hs.add("darban");
        hs.add(3.14159);
        hs.add(new Date());

黃彥霖 發表在 痞客邦 留言(0) 人氣()

public static void main(String [] args){

    int a = 5;

    if(a==5){

        System.out.println("中斷啦");

        return;

    }

    System.out.println("程式沒有中斷");

//-----------------------------------------------------

//--  語法 :     assert <布林值> : <輸出>;

黃彥霖 發表在 痞客邦 留言(0) 人氣()

//  此方法會編譯錯誤,因為 return 可能不執行

int run(int a){

    if(a > 0){

        return 0;

    }

}


黃彥霖 發表在 痞客邦 留言(0) 人氣()

先建立A.txt,輸入 :    <br>123<br>abc<br>456<br>

 

 

import java.io.*;
import java.util.*;

public class A{
public static void main(String [] args) throws Exception{

Scanner s = new Scanner(new File("A.txt"));
s.useDelimiter("<br>");
while(s.hasNext()){

黃彥霖 發表在 痞客邦 留言(0) 人氣()

import java.io.*;
import java.net.*;
public class Downloader{
public static void main(String[] args)throws IOException{
URL url=new URL("http://163.20.63.180/javaroom/midi/alas/Other/td.mid");

InputStream is=url.openStream();

FileOutputStream fos=new FileOutputStream("td.mid");
while(true){
int i=is.read();
if(i==-1)

黃彥霖 發表在 痞客邦 留言(0) 人氣()

import java.io.*;

public class A{
public static void main(String [] args) throws Exception{

File f = new File("gg.txt");
FileReader fr = new FileReader(f);
char [] fc = new char [(int)f.length()];
fr.read(fc);
fr.close();

String s = new String(fc);
System.out.print(s);

黃彥霖 發表在 痞客邦 留言(0) 人氣()

//----------------------------------------------------覆蓋原有

import java.io.*;

public class A{
public static void main(String [] args) throws Exception{

FileWriter fw = new FileWriter("gg.txt");
fw.write("你好!!");
fw.close();
}
}

//---------------------------------------------------加在尾端

黃彥霖 發表在 痞客邦 留言(0) 人氣()

變數(variable) = 欄位(Java官方使用) = 狀態 = 屬性 

型別 : 包含 基本型別、類別


黃彥霖 發表在 痞客邦 留言(0) 人氣()

// Student.java檔案

public class Student{
     String name;
     int scoreA,scoreB,scoreC;
}

// SetData.java檔案

 

public class SetStudent{
    public static void main(String[] args){

        Student snew Student();

黃彥霖 發表在 痞客邦 留言(3) 人氣()