在Java內:
HashMap<String, String> testHashMap = new HashMap<>(); testHashMap.put( "1", "Kim" ); testHashMap.put( "2", "Dick" ); for( String key : testHashMap.keySet() ) { System.out.println( key + " = " + testHashMap.get( key ) ); }--------------------------------------------------------------------------------------------------------
在JavaScript內:
var testHashMap= {}; testHashMap['1'] = 'Kim'; testHashMap['2'] = 'Dick'; for( var key in testHashMap ) { alert( key + ' = ' + testHashMap[key] ); }
沒有留言:
張貼留言