现在的位置: 首页 > 综合 > 正文

Java中使用split、sort函数

2018年04月09日 ⁄ 综合 ⁄ 共 401字 ⁄ 字号 评论关闭
  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

抱歉!评论已关闭.