Java中使用split、sort函数

来源:互联网 发布:程序员饱和了吗 编辑:程序博客网 时间:2024/06/05 20:42
  1. public static void main(String[] args) { 
  2.     // TODO Auto-generated method stub 
  3.     String str = null ; 
  4.     Scanner scan = new Scanner(System.in); 
  5.     str=scan.nextLine(); 
  6.     System.out.println(str); 
  7.     String[] arr = str.split(" "); 
  8.     Arrays.sort(arr); 
  9.     for(int i=0;i<arr.length;i++) 
  10.         System.out.print(arr[i]+"   "); 

 

 

本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/813941

0 0