Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JAVAʵÀý½Ì³ÌÖ®5

½Ì³Ì5 ËãÊýÔËËãѧϰ³ÌÐò ѧϰĿ±ê 5.1¼òµ¥¼Ó·¨Ñ§Ï°³ÌÐò СѧÉúÔÚ¸Õ¸Õ¿ªÊ¼Ñ§Ï°ÊýѧÔËËãµÄʱºò£¬ÐèÒª²»¶ÏµØ½øÐз´¸´´óÁ¿µÄÁ·Ï°£¬²ÅÄܹ»Ñ¸ËÙÕÆÎÕÕⲿ·ÖÄÚÈÝ¡£ÏÂÃ濪·¢Ò»¸ö¼òµ¥µÄ¼Ó·¨Ñ§Ï°³ÌÐò£¬Äܹ»²úÉú¼Ó·¨ÔËËãÈÃѧÉúÀ´Ñ§Ï°Ìá¸ß¡£ ±àд³ÌÐòÈçÏ£º 1 package lesson5; 2 3 public class Operation1 { 4 int number1; 5 int number2; 6 void operate(int number1,int number2) 7 { 8 this.number1=number1; 9 this.number2=number2; 10 System.out.println(number1+"+"+number2+"="); 11 } 12 void showTitle() 13 { 14 System.out.println("Çë¼ÆËãÈçÏÂÔËËã½á¹û£º"); 15 } 16 public static void main(String args[]) 17 { 18 Operation1 o1=new Operation1(); 19 o1.showTitle(); 20 o1.operate(1,2); 21 } 22 } ±¾³ÌÐòÖУ¬¶¨ÒåÁËÒ»¸öOperation1Àà¡£ÀàÖж¨ÒåÁËÁ½¸öintÀàÐ͵ıäÁ¿number1ºÍnumber2£¬·Ö±ðÓÃÀ´´æ´¢²ÎÓëÔËËãµÄÁ½¸öÊý×Ö¡£µÚ6¡«11Ðж¨ÒåÁËÒ»¸öoperateº¯ÊýÓÃÀ´²úÉúÒ»¸ö¼Ó·¨ÔËËã¡£·½·¨ÌåÄÚ£¬µÚ8¡¢9ÐÐÊ×ÏÈÓ¦Ó÷½·¨µÄ²ÎÊý¶Ôµ±Ç°¶ÔÏóµÄnumber1ºÍnumber2½øÐи³Öµ£¬µÚ11ÐÐÍê³ÉÁËÔËËãʽµÄÊä³ö¡£µÚ12¡«15Ðж¨ÒåÁË·½·¨showTitle£¬·½·¨ÌåÄÚµÄ14ÐдòÓ¡Á˼ӷ¨ÔËËãµÄÌáʾÐÅÏ¢¡£µÚ16¡«22ÐÐÊÇmainº¯Êý£¬º¯ÊýÌåÄÚµÚ18ÐÐÊ×Ïȶ¨ÒåÁËÒ»¸ö¶ÔÏóo1£¬½ÓÏÂÀ´µÚ19Ðе÷ÓÃÁËshowTitle·½·¨£¬×îºóo1µ÷ÓÃÁËoperate·½·¨¡£ ±àÒë¡¢ÔËÐгÌÐò£¬½«µÃµ½ÈçϽá¹û£º Çë¼ÆËãÈçÏÂÔËËã½á¹û£º 1+2= 5.2 ÒýÈëËæ»úÊýµÄ¼Ó·¨Ñ§Ï°³ÌÐò ÉÏÊö³ÌÐòÔÚʹÓÃÖÐÈç¹ûÐèÒª²úÉú¼Ó·¨Ëãʽ£¬ÐèÒªÊÂÏÈÈ·¶¨Á½¸ö¼ÓÊý£¬ÕâÑù²Ù×÷ÆðÀ´Ïà¶Ô±È½ÏÂé·³£¬¶øÔÚʵ¼ÊʹÓÃÖÐͨ³£Ï£ÍûÄܹ»×Ô¶¯²úÉúÁ½¸ö¼ÓÊý¡£ Èç¹ûÏ£Íû×Ô¶¯²úÉú¼ÓÊý£¬¾ÍÒªÓõ½Ëæ»úÊý¡£ ÔÚJavaÓïÑÔÖÐÀàRandomÓÃÀ´²úÉúËæ»úÊý¡£Òò´Ë£¬¿ÉÒÔÏÈÓÃÀàRandomÉú²úÒ»¸ö¶ÔÏó£¬ÔÙͨ¹ýÕâ¸ö¶ÔÏóÉú³ÉËæ»úÊý¡£RandomÔÚJavaÖÐÍê³ÉµÄ·¾¶ÊÇjava.util.Random£¬Òò´ËRandom¶ÔÏóÉú³É·½Ê½Îª£º java.util.Random ¶ÔÏóÃû=new java.util.Random(); ¿ÉÒÔ¿´µ½Èç¹ûÕâÑù¶¨Òå±È½ÏÂé·³£¬Òò´ËÒýÈëimportÓï¾ä¡£ÔÚ³ÌÐòµÄ¿ªÊ¼²¿·ÖÓ¦ÓÃimportÒýÈëjava.util.Random£¬ÕâÑùÿ´ÎÓõ½RandomµÄʱºò£¬¾Í¿ÉÒÔÖ±½ÓʹÓÃÁË¡£ÀýÈ磺 Random ¶ÔÏóÃû= Random(); ÔÚRandomµÄ·½·¨ÀïÃæ¾­³£Óõ½ÊÇnextInt(int n)·½·¨¡£¸Ã·½·¨·µ»ØÒ»¸öαËæ»úÊý£¬ËüÊÇ´Ó´ËËæ»úÊýÉú³ÉÆ÷µÄÐòÁÐÖÐÈ¡³öµÄÔÚ 0£¨°üÀ¨£©ºÍÖ¸¶¨Öµ£¨²»°üÀ¨£©Ö®¼ä¾ùÔÈ·Ö²¼µÄ intÖµ¡£ Ð޸ijÌÐòÈçÏ£º 1 package lesson5; 2 import


Ïà¹ØÎĵµ£º

ÔÚEclipseºÍNetBeansÖе¼ÈëJava API

 ¹¤ÓûÉÆÆäÊ£¬±ØÏÈÀûÆäÆ÷¡£ÊìϤ¿ª·¢»·¾³¿ÉÒÔÈÃÄã¸ü¿ì¸üºÃ¸üÊæ·þµØ¿ª·¢Èí¼þ¡£¾ÍÈçͬVC/.net¿ª·¢ÈËÔ±Àë²»¿ªmsdn£¬java¿ª·¢ÈËÔ±ÍùÍùÒ²Àë²»¿ªjava API¡£ÏÂÃæ½éÉÜÏÂÈçºÎÔÚEclipseºÍNetBeansÖе¼Èëjava API¡£Ê¹Ö®¿ÉÒÔ·½±ã¿ìËٵزéÕÒ£¬¶¨Î»¡£
¡¡¡¡±¾ÎÄÊʺÏÓë¸Õ¸Õ½Ó´¥Eclipse»òNetBeansµÄjava¿ª·¢ÈËÔ±£¬»òÕßÊÇÓо­ÑéµÄʹÓÃEc ......

JavaÖеÄ×Ö·û¼¯±àÂëÈëÃÅ 2

 
¡¡¡¡Ëµµ½GB2312ºÍGBK¾Í²»µÃ²»ÌáÖÐÎÄÍøÒ³µÄ±àÂë¡£¾¡¹ÜºÜ¶àпª·¢µÄWebϵͳºÍÐÂÉÏÏßµÄ×¢Öعú¼Ê»¯µÄÍøÕ¾¶¼¿ªÊ¼Ê¹ÓÃUTF-8£¬ÈÔÓÐÏ൱һ²¿·ÖµÄÖÐÎÄýÌå¼á³ÖʹÓÃGB2312ºÍGBK£¬ÀýÈçÐÂÀ˵ÄÒ³Ãæ¡£ÆäÖÐÓÐÁ½µãºÜÖµµÃ×¢Òâ¡£
¡¡¡¡µÚÒ»£¬Ò³ÃæÖÐmeta±êÇ©µÄ²¿·Ö£¬³£³£¿ÉÒÔ¼ûµ½charset=GB2312ÕâÑùµÄд·¨£¬ºÜ²»ÐÒµÄÊÇ£¬Õâ¸ö“cha ......

Javaѧϰ±Ê¼Ç¢Ü

 Ñ§Ï°Java³ÌÐòÖ÷Òª°üº¬ÒÔÏÂËĸö²¿·Ö¡£
(1)±à¼­´úÂë  edit code
(2)±£´æ´úÂë  save code
(3)±àÒë´úÂë  compiler code
(4)ÔËÐгÌÐò  run program
µÚÒ»¸ö³ÌÐòÎļþHelloWorld.java
public class HelloWorld {
   public static void main(String[] args){
     ......

JavaÖÐÇó100µÄ½×³Ë

 Ê¹ÓÃBigInteger´óÈÝÁ¿ÔËËãÀà¼ÆËã100µÄ½×³Ë
Ò».Ò»°ãËã·¨(Ñ­»·)
public class Test {
public static void main(String[] args) {
int result = 1;
for (int i = 1; i <= 100; i++) {
result *= i;
}
System.out.println(result);
}
}
Êä³ö½á¹ûΪ0£¬ÒòΪintÎÞ·¨±£´æÏÂ100µÄ½×³ËµÄ½á¹û£¬100µ ......

java¶ÁÈ¡XMLÎļþÀïÃæµÄÊý¾ÝÖ®DOMʵÏÖ

import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.*;
public class ReadXML {
private File file;

public ReadXML(String filename){
File file=new File(filename);
this.file=file;
}
/**
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ