对数字段进行排序,String,Integer,Arrays,ArrayList,Scanner
来源:互联网 发布:武术器械大全 淘宝 编辑:程序博客网 时间:2024/04/30 01:51
package test;import java.util.ArrayList;import java.util.Arrays;import java.util.Scanner;public class LianXi { public static void main(String[] args) { System.out.println("Enter the number, enter 's' to exit:"); ArrayList<Integer> list = new ArrayList<>(); String s = ""; do { Scanner scanner = new Scanner(System.in); s = scanner.nextLine(); if (s.equals("s")) { break; } else { list.add(Integer.parseInt(s)); } } while (!s.equals("s")); int[] ints = new int[list.size()]; for (int i = 0; i < list.size(); i++) { ints[i] = list.get(i); } Arrays.sort(ints); for (int i : ints) { System.out.println(i + ""); } }}/*Stringboolean equals(Object anObject) // ""Compares this string to the specified object.Integerstatic int parseInt(String s)Parses the string argument as a signed decimal integer.static int parseInt(String s, int radix)Parses the string argument as a signed integer in the radix specified by the second argument.Arraysstatic void sort(byte[] a)Sorts the specified array into ascending numerical order.static void sort(byte[] a, int fromIndex, int toIndex)Sorts the specified range of the array into ascending order.ArrayList<object>boolean add(E e)Appends the specified element to the end of this list.E get(int index)Returns the element at the specified position in this list.remove()set()size()contains()ScannerScanner(InputStream source)Constructs a new Scanner that produces values scanned from the specified input stream.String nextLine()Advances this scanner past the current line and returns the input that was skipped. */
阅读全文
0 0
- 对数字段进行排序,String,Integer,Arrays,ArrayList,Scanner
- java Collections Arrays ArrayList 类的运用 进行对象排序
- ArrayList对动态数组进行排序数组由Scanner后台动态接收数组元素
- HashMap<String, ArrayList<Integer>>用法
- Arrays . sort 进行快速排序
- Java中 键盘录入Scanner,String与 Integer数据类型转换
- ArrayList<Object> 转换为Map<Integer, ArrayList<String>>
- list,ArrayList集合进行排序
- Arrays , Collections , Scanner , Runtime
- Scanner,String
- 对ArrayList<HashMap<String, String>>排序
- java ArrayList<Map<String,String>>排序
- 数组_用Arrays.sort()进行排序
- Java Arrays类进行数组排序
- 【Java】Java Arrays类进行数组排序
- Java Arrays类进行数组排序
- Java Arrays类进行数组排序
- 使用Java Arrays类进行数组排序
- [HAOI2007]反素数ant
- Ubuntu 16.04 解决无法重复按键的问题
- [TensorFlow] ubuntu16.04 pip3安装 TensorFlow
- Java实现九大排序算法
- Windows下升级node.js版本方法
- 对数字段进行排序,String,Integer,Arrays,ArrayList,Scanner
- 统计学之三大相关性系数(pearson、spearman、kendall)
- makeself与deb打包与简单的makeself转deb的方式,简单明了!
- 匿名对象
- 块设备内核参数max_segments和max_sectors_kb解析
- Fresco源码分析之DraweeView
- 秒杀系统架构优化思路
- bash和shell的区别
- Vue入门系列之Vue实例详解与生命周期