2013年7月2日 星期二

XPages: Simple function to clear scoped variables

All scope objects (applicationScope, sessionScope, etc.) are maps, so it's quite easy to clear them. This might come in handy during development, if you want to clear the applicationScope.

I've tested it on both applicationScope and sessionScope, and it doesn't seem to do any harm. After the maps are cleared, the server automatically loads the "internal" values used by the system.

function clearMap( map:Map ){
 // Get iterator for the keys
 var iterator = map.keySet().iterator();
 
 // Remove all items
 while( iterator.hasNext() ){
  map.remove( iterator.next() );
 }
}

Usage:
clearMap( applicationScope )

 轉載自DontPanic - a blog about Lotus Notes / Domino

2013年3月12日 星期二

how can I remove brackets from this array?

方法一:

import java.util.*;

public class RandomArray {
    public static void main( String[] args ) {

        Random random = new Random();

        int[][] array = new int[19][19];

        for( int i = 0 ; i < array.length ; i++ ) {
           for ( int j = 0 ; j < array[i].length ; j++ ) {
              array[i][j] = random.nextInt(3-0);
           }
        }

        for( int[] a : array ) {
            System.out.println( Arrays.toString( a ).replace("[", "").replace("]", ""));            
        }


    }
   
}
方法二:

System.out.println(Arrays.toString(a).replaceAll("^\\[|\\]$"));

資料來源:
http://www.dreamincode.net/forums/topic/288259-how-can-i-remove-brackets-from-this-array/