JavaµÄContainerʾÀý³ÌÐò
package com.tiantian;
import java.util.*;
public class JAVAContainer {
public static void main(String[] args) throws Exception {
// ArrayList
{
ArrayList arraylist = new ArrayList();
arraylist.add(0, "end");//Ö¸¶¨Ë÷Òý¼ÓÈëÖµ
// Ðè×¢ÒâµÄÊÇ£¬Èç¹ûÏÖÓÐ2¸öÖµ£¬ÎÒÓÈëË÷Ò?µÄÄÇô¾Í»á³öÏÖÒì³£
for (int i = 0; i < 2; i++) {
arraylist.add(i, String.valueOf(i));
}
System.out.println("ArrayList:");
for (int i = 0; i < arraylist.size(); i++) {
System.out.print(arraylist.get(i) + ";");
}
arraylist.add("0");//Ö±½Ó¼ÓÈëÖµµ½ArrayListµÄ×îºó
arraylist.add("0");
System.out.print(" ArrayList's lastIndexOf("0") is "
+ arraylist.lastIndexOf("0"));
}
// Arrays
{
String[] array = new String[] { "a", "b", "c" };
List list = Arrays.asList(array);
System.out.println(" Arrays:");
for (int i = 0; i < list.size(); i++) {
System.out.print(list.get(i) + ";");
}
System.out.print(" Arrays's length is " + array.length);//´òÓ¡Êý×éµÄ³¤¶È
}
// Collections
{
String[] array = new String[] { "a", "b", "c" };
List list = Arrays.asList(array);
Collections.fill(list, "Fill");//ÓÃFillÌî³äÈ«²¿ÔªËØ
System.out.println(" Collections:");
for (int i = 0; i < list.size(); i++) {
System.out.print(list.get(i) + ";");
}
array = new String[] { "1", "2", "3" };
List list2 = Arrays.asList(array);
Collections.copy(list, list2);//¿½±´list2µÄÊý¾Ý½ølist
System.out.println(" " + list);
Collections.swap(list, 2, 1);//µ÷»»Ë÷ÒýΪ1ºÍ2µÄÔªËصÄλÖÃ
System.out.println(list);
}
// EventObject
{
String s = "hello";
String s2 = s;
EventObject eventobject = new EventObject(s);//Ò»¸ö×¼ÈÝÆ÷ÀàÐÍ£¬È·ÇеĹéÀàËü²»ÊÇÈÝÆ÷
System.out.println("EventObject:");
System.out.println(eventobject.getSource());
System.out.println(eventobject.equals(s2));
}
// HashMap
{
HashMap hashmap = new HashMap();//Ò»¸öËÙ¶È×î¿ìµÄÈÝÆ÷
hashmap.put("0", "c");
hashmap.put("1", "a");
hashmap.put("2", "b");
hashmap.put("3", "a");
System.out.println("HashMap:");
System.out.println(hashmap);//¸ÃÈÝÆ÷ÓÐ
Ïà¹ØÎĵµ£º
Ò»¡¢²»±äģʽ£º
Ò»¸ö×Ö·û´®¶ÔÏó´´½¨ºóËüµÄÖµ²»Äܸı䡣
String str1="hello";//´´½¨Ò»¸ö¶ÔÏóhello£¬²»»á±ä£»
System.out.println(str1);
str1+=" world!";//Á½¸ö×Ö·û´®¶ÔÏóÕ³Õ³£¬ÏµÍ³Æäʵ´´½¨ÁËÒ»¸öеĶÔÏ󣬰ÑStr1µÄÖ¸Ïò¸ÄÁË£¬Ö¸ÏòеĶÔÏó£»hello¾Í & ......
Java6 ½Å±¾ÒýÇæ(ÓÃJavaµ÷ÓÃJS½Å±¾)µ÷ÓÃjs
import java.io.FileNotFoundException;
import java.io.FileReader;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
&n ......
java³£ÓÃÀàµÄʹÓ÷½·¨
Interger£ºÕûÊýÀàÐÍ
£±¡¢ÊôÐÔ¡£
static int MAX_VALUE£º·µ»Ø×î´óµÄÕûÐÍÊý£»
static int MIN_VALUE£º·µ»Ø×îСµÄÕûÐÍÊý£»
static Class TYPE £º·µ»Øµ±Ç°ÀàÐÍ¡£
Àý×Ó£º
´úÂë:
System.out.println("Integer.MAX_VALUE: " + Integer.MAX_VALUE );
½á¹ûΪ£ºInteger.MAX_VALUE: 2147483647
&nb ......
ÔÌùÄÚÈÝÇë¼û: http://topic.csdn.net/u/20100116/17/6a204504-9e70-435f-be55-f0630ed12fdf.html?seed=942806558&r=62778073#r_62778073
Çë´óÅ£Ö¸Õý.
²úÆ·Àà:
package selfimpr.producerCustomer;
/**
* ²úÆ·
* @author selfimpr
* @blog http://blog.csdn.net/lgg201
* @email lgg860911@yahoo.com.cn
......
Õâ¸öËã·¨¼òµ¥,¶øÇÒЧÂʸß,ÿ´Î¿ÉÒÔ²Ù×÷8¸ö×Ö½ÚµÄÊý¾Ý,¼ÓÃܽâÃܵÄKEYΪ16×Ö½Ú,¼´°üº¬4¸öintÊý¾ÝµÄintÐÍÊý×é,¼ÓÃÜÂÖÊýӦΪ8µÄ±¶Êý,Ò»°ã±È½Ï³£ÓõÄÂÖÊýΪ64,32,16,ÍƼöÓÃ64ÂÖ.
Ô´´úÂëÈçÏÂ:
/** *//**
* TeaËã·¨
* ÿ´Î²Ù×÷¿ÉÒÔ´¦Àí8¸ö×Ö½ÚÊý¾Ý
* KEYΪ16×Ö½Ú,ӦΪ°üº¬4¸öintÐÍÊýµÄint[]£¬Ò»¸öintΪ4¸ö×Ö½Ú
* ¼ÓÃܽâÃÜÂÖÊ ......