1. 程式人生 > >java:輸入一個數,反轉後輸出

java:輸入一個數,反轉後輸出

public class TEST {

	public long reverse(long num){
		
		String strnum = String.valueOf(num);
		
		StringBuffer buffer = new StringBuffer();
		
		for(int i=0;i<strnum.length();i++){
			buffer.append(strnum.charAt(strnum.length()-i-1));
		}
		long target = Integer.parseInt(buffer.toString());
		
		
		return target;
		
	}
	public static void main(String[] args) {
		long num = 248765432;
		TEST test = new TEST();
		System.out.println(test.reverse(num));
	}
}