ÕÅТÏé¡¶Java¾ÍÒµÅàѵ½Ì³Ì¡·Ô´´úÂë 02 ²¿·Ö
¡¶Java¾ÍÒµÅàѵ½Ì³Ì¡· ×÷ÕߣºÕÅТÏé ÊéÖÐÔ´Âë
¡¶Java¾ÍÒµÅàѵ½Ì³Ì¡·P34Ô´Âë
³ÌÐòÇåµ¥£ºPromote.java
class Promote
{
public static void main(String args[])
{
byte b = 50;
char c = 'a';
short s = 1024;
int i = 50000;
float f = 5.67f;
double d = .1234;
double result = (f * b) + (i / c) - (d * s);
System.out.println((f * b) + " + " + (i / c) + " - " + (d * s));
System.out.println("result = " + result);
}
}
¡¶Java¾ÍÒµÅàѵ½Ì³Ì¡·P35Ô´Âë
³ÌÐòÇåµ¥£ºTestScope.java
public class TestScope
{
public static void main(String[] args)
{
int x = 12;
{
int q = 96; // xºÍq¶¼¿ÉÓÃ
System.out.println("x is "+x);
System.out.println("q is "+q);
}
q = x; /* ´íÎóµÄÐУ¬Ö»ÓÐx¿ÉÓ㬠q ³¬³öÁË×÷ÓÃÓò·¶Î§ */
System.out.println("x is "+x);
}
}
¡¶Java¾ÍÒµÅàѵ½Ì³Ì¡·P37Ô´Âë
³ÌÐòÇåµ¥£ºTestVar.java
public class TestVar
{
public static void main(String [] args)
{
int x;//Ó¦¸ÄΪint x=0;
x=x+1; //Õâ¸öxÓÉÓÚûÓгõʼ»¯£¬±àÒë»á±¨´í¡£
System.out.println("x is "+x);
}
}
³ÌÐòÇåµ¥£ºFunc1.java
public class Func1
{
public static void main(String [] args)
{
/* ÏÂÃæÊÇ´òÓ¡³öµÚÒ»¸ö¾ØÐεijÌÐò´úÂë*/
for(int i=0;i<3;i++)
{
for(int j=0;j<5;j++)
{
System.out.print("*");
&
Ïà¹ØÎĵµ£º
public class P {
public static void main(String[] args){
String pattern="000";
java.text.DecimalFormat df = new java.text.DecimalFormat(pattern);
int i = 10,j=6;
System.out.println("i="+df.format(i)+"\nj="+df.format(j));
}
}
---------------------Êä³ö-----------------------
i=010 ......
javaѧϰ:³¹µ×Ã÷°×JavaµÄIOϵͳ
ÎÄÕÂÀ´Ô´£º»¥ÁªÍø
Ò»£® InputºÍOutput
1. stream´ú±íµÄÊÇÈκÎÓÐÄÜÁ¦²ú³öÊý¾ÝµÄÊý¾ÝÔ´£¬»òÊÇÈκÎÓÐÄÜÁ¦½ÓÊÕÊý¾ÝµÄ½ÓÊÕÔ´¡£ÔÚJavaµÄIOÖУ¬ËùÓеÄstream£¨°üÀ¨InputºÍOut stream£©¶¼°üÀ¨Á½ÖÖÀàÐÍ£º
1.1 ÒÔ×Ö½ÚΪµ¼ÏòµÄstream
ÒÔ×Ö½ÚΪµ¼ÏòµÄstream£¬±íʾÒÔ×Ö½ÚΪµ¥Î»´ÓstreamÖжÁÈ¡»òÍùst ......
javaÖÐÒì³£µÄÁ½ÖÖ´¦Àí£º
1.try...catch....finally ´æÔÚÓ뵱ǰµÄÒì³£´¦ÀíÀ࣬±íʾµ±Ç°ÓÉ×Ô¼ºµÄ·½·¨À´´¦Àí
2.Throw ½«µ±Ç°Òì³£Å׳ö £¬½»ÓÉÉϼ¶À´´¦Àí¡£
try...catch....finallyµÄ´¦ÀíÁ÷³Ì£º
½«³öÏÖÒì³£µÄÓï¾ä·ÅÔÚtryÖУ¬Ò»¶Î´ËÓï¾ä³ö´í£¬³ÌÐò»áÔÝÍ£Ö´ÐУ¬Òì³£´¦Àí»úÖÆ¾ÍÈ¥½Ó¹Ü³ÌÐò£¬
½ ......
/**ÎÒÕâÖ»½² ListArray ,ListedList,HashMap
//ListArray ËüÊÇÒ»¸öʵÏÖÁËList½Ó¿ÚµÄÀà ,List¼Ì³Ðcollection½Ó¿Ú
//µ÷ÓÃimport java.util.ArrayList°ü,(ÕâÀïÁ½ÕßÈÎÑ¡ÆäÒ») ÍêÕûµÄjava¼¯ºÏ´æ·ÅÔÚjava.util°üÖÐ
//ÌØµã:
1>.ListÊÇÓÐÐòµÄ¼¯ºÏ
2>.List¿ÉÒÔÓÐÖØ¸´µÄÔªËØÖµ
3>.ʹÓÃË÷ÒýÀ´¾«È·µÄ·ÃÎÊÔªËØÖµ,
4& ......
class Link
{
private Node head;
public Link(Node head)
{
this.head=head;
}
public void addNode(Node node)
{
Node p=head;
while(true)
{
if(!p.hasNext())
{
p.setNext(node);
break;
}
p=p.getNext();
}
}
//²åÈë½Ú
public void insertNode(Node p,Node q)
{
q.setNext(p.getNext());
p.se ......