JAVAÁ·Ï°Ìâ
¡ñÒÑÖªÔ²µÄÃæ»ýArea=π*r*r£¬Çó°ë¾¶r¡£
import javax.swing.JOptionPane;
public class T6 {
public static void main(String args[]) {
String s = JOptionPane.showInputDialog("ÇëÊäÈëÔ²Ãæ»ý£º");
double Area = Double.parseDouble(s);
double r;
r = Math.sqrt(Area / Math.PI);
JOptionPane.showMessageDialog(null, "¸ÃÔ²°ë¾¶Îª£º" + r, "°ë¾¶Öµ",
JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
¡ñʹÓÃMathÀàÖеÄrandom()·½·¨£¬Ä£ÄâÒ»¸öÍ°åÔÚÁ¬ÐøÒ»°Ù´ÎµÄͶÖÀÖУ¬³öÏÖÕý·´Ãæ´ÎÊý¡£
public class T7 {
public static void main(String args[]) {
int zm = 0;
int fm = 0;
for (int k = 0; k < 100; k++) {
if (Math.random() > 0.5) {
zm++;
} else {
fm++;
}
}
System.out.println("·´Ãæ´ÎÊýΪ£º" + fm + "\nÕýÃæ´ÎÊýΪ£º" + zm);
}
}
¡ñÄ£ÄâÒ»¸ö÷»×ÓÔÚÁ¬ÐøÒ»Íò´ÎµÄͶÖÀÖУ¬Ò»ÖÁÁùµã³öÏÖ´ÎÊý¡£
import java.util.Random;
public class T8 {
public static void main(String args[]){
int[] t = new int[6];
Random rand = new Random();
for(int i=0;i<10000;i++)
{
int r = rand.nextInt(6) +1 ;//Éú³É1µ½6µÄÕûÊý
switch(r){
case 1: t[0]++;break;
case 2: t[1]++;break;
case 3: t[2]++;break;
case 4: t[3]++;break;
case 5: t[4]++;break;
default : t[5]++;
}
}
for(int i=0;i<t.length;i++)
{
Ïà¹ØÎĵµ£º
1. Ëõ½øÅÅ°æ(Indentation)
4¸ö¿Õ¸ñ³£±»×÷ΪËõ½øÅÅ°æµÄÒ»¸öµ¥Î»¡£Ëõ½øµÄÈ·ÇнâÊͲ¢Î´Ïêϸָ¶¨(¿Õ¸ñ vs. ÖƱí·û)¡£Ò»¸öÖƱí·ûµÈÓÚn¸ö¿Õ¸ñ(ÊÓ¾ßÌåµÄ±à¼Æ÷¶ø¶¨£¬EclipseĬÈÏÒ»¸öÖƱí·ûΪ4¸ö×Ö·û)¡£
3.1 Ð㤶È(Line Length)
¾¡Á¿±ÜÃâÒ»Ðеij¤¶È³¬¹ý80¸ö×Ö·û£¬ÒòΪºÜ ......
1¡¢jspºÍservletµÄÇø±ð¡¢¹²Í¬µã¡¢¸÷×ÔÓ¦Óõķ¶Î§£¿£¿
JSPÊÇServlet¼¼ÊõµÄÀ©Õ¹£¬±¾ÖÊÉϾÍÊÇServletµÄ¼òÒ×·½Ê½¡£JSP±àÒëºóÊÇ“Ààservlet”¡£ServletºÍJSP×îÖ÷ÒªµÄ²»Í¬µãÔÚÓÚ£¬ServletµÄÓ¦ÓÃÂß¼ÊÇÔÚJavaÎļþÖУ¬²¢ÇÒÍêÈ«´Ó±íʾ²ãÖеÄHTMLÀï·ÖÀ뿪À´¡£¶øJSPµÄÇé¿öÊÇJavaºÍHTML¿ÉÒÔ×éºÏ³ÉÒ»¸öÀ©Õ¹ÃûΪ.jspµÄÎļþ¡£J ......
JavaÏß³ÌÊÇJavaÓïÑÔÖÐÒ»¸ö·Ç³£ÖØÒªµÄ²¿·Ö£¬Java5֮ǰ£¬¶àÏ̵߳ÄÓïÑÔÖ§³Ö»¹ÊDZȽÏÈõµÄ£¬ÄÚÈÝÒ²½ÏÉÙ£¬Ð´Ò»¸ö¸´ÔӵĶàÏ̳߳ÌÐòÊÇÏ൱ÓÐÌôÕ½ÐԵġ£
ÔÚJava5ÒÔºó£¬Java¶Ô¶àÏß³Ì×öÁ˺ܶàÀ©Õ¹£¬À©Õ¹²¿·Ö³Æ֮Ϊ²¢·¢°ü¡£Õⲿ·ÖÄÚÈÝ´ó´óÔöÇ¿ÁËJava¶àÏ̱߳à³ÌµÄÄÜÁ¦£¬Í¨¹ýʹÓÃJava5Ïß³ÌÐÂÌØÕ÷µÄAPI£¬¿ÉÒÔºÜÈÝÒ×µÄ×ö³ö¸´Ô ......
¶ÔÏóÐòÁл¯(Serializable)ÊÇÖ¸½«¶ÔÏóת»»Îª×Ö½ÚÐòÁеĹý³Ì£¬¶ø·´ÐòÁл¯ÔòÊǸù¾Ý×Ö½ÚÐòÁлָ´¶ÔÏóµÄ¹ý³Ì¡£
ÐòÁл¯Ò»°ãÓÃÓÚÒÔϳ¡¾°£º
1.ÓÀ¾ÃÐÔ±£´æ¶ÔÏ󣬱£´æ¶ÔÏóµÄ×Ö½ÚÐòÁе½±¾µØÎļþÖУ»
2.ͨ¹ýÐòÁл¯¶ÔÏóÔÚÍøÂçÖд«µÝ¶ÔÏó£»
3.ͨ¹ýÐòÁл¯ÔÚ½ø³Ì¼ä´«µÝ¶ÔÏó¡£
¶ÔÏóËùÊôµÄÀà±ØÐëʵÏÖSerializable»òÊÇExternalizable½Ó¿Ú ......
Ò»¡¢Ï̸߳ÅÊö
Ïß³ÌÊdzÌÐòÔËÐеĻù±¾Ö´Ðе¥Ôª¡£µ±²Ù×÷ϵͳ(²»°üÀ¨µ¥Ï̵߳IJÙ×÷ϵͳ£¬Èç΢ÈíÔçÆÚµÄDOS)ÔÚÖ´ÐÐÒ»¸ö³ÌÐòʱ£¬»áÔÚϵͳÖн¨Á¢Ò»¸ö½ø³Ì£¬¶øÔÚÕâ¸ö½ø³ÌÖУ¬±ØÐëÖÁÉÙ½¨Á¢Ò»¸öỊ̈߳¨Õâ¸öÏ̱߳»³ÆΪÖ÷Ị̈߳©À´×÷ΪÕâ¸ö³ÌÐòÔËÐеÄÈë¿Úµã¡£Òò´Ë£¬ÔÚ²Ù×÷ϵͳÖÐÔËÐеÄÈκγÌÐò¶¼ÖÁÉÙÓÐÒ»¸öÖ÷Ï̡߳£
½ø³ÌºÍÏß³ÌÊÇÏÖ´ú²Ù× ......