Top 10 Methods for Java Arrays
作者:X Wang
出处:http://www.programcreek.com/2013/09/top-10-methods-for-java-arrays/
转载文章,转载请注明作者和出处
The following are top 10 methods for Java Array. They are the most voted questions from stackoverflow.
0. Declare an array
String[] aArray = new String[5]; |
1. Print an array in Java
int[] intArray = { 1, 2, 3, 4, 5 };
|
2. Create an ArrayList from an array
String[] stringArray = { "a", "b", "c", "d", "e" };
|
3. Check if an array contains a certain value
String[] stringArray = { "a", "b", "c", "d", "e" };
|
4. Concatenate two arrays
int[] intArray = { 1, 2, 3, 4, 5 };
|
5. Declare an array inline
method(new String[]{"a", "b", "c", "d", "e"});
|
6. Joins the elements of the provided array into a single String
// containing the provided list of elements |
7. Covnert an ArrayList to an array
String[] stringArray = { "a", "b", "c", "d", "e" };
|
8. Convert an array to a set
Set<String> set = new HashSet<String>(Arrays.asList(stringArray)); |
9. Reverse an array
int[] intArray = { 1, 2, 3, 4, 5 };
|
10. Remove element of an array
int[] intArray = { 1, 2, 3, 4, 5 };
|
One more - convert int to byte array
byte[] bytes = ByteBuffer.allocate(4).putInt(8).array(); |
Top 10 Methods for Java Arrays的更多相关文章
- 【翻译】Java Array的排名前十方法(Top 10 Methods for Java Arrays)
这里列举了Java Array 的前十的方法.他们在stackoverflow最大投票的问题. The following are top 10 methods for Java Array. The ...
- Top 10 Questions about Java Exceptions--reference
reference from:http://www.programcreek.com/2013/10/top-10-questions-about-java-exceptions/ This arti ...
- Top 10 questions about Java Collections--reference
reference from:http://www.programcreek.com/2013/09/top-10-questions-for-java-collections/ The follow ...
- Top 10 Mistakes Java Developers Make--reference
This list summarizes the top 10 mistakes that Java developers frequently make. #1. Convert Array to ...
- Top 10 Mistakes Java Developers Make(转)
文章列出了Java开发者最常犯的是个错误. 1.将数组转换为ArrayList 为了将数组转换为ArrayList,开发者经常会这样做: ? 1 List<String> list = A ...
- Top 10 Algorithms for Coding Interview--reference
By X Wang Update History:Web Version latest update: 4/6/2014PDF Version latest update: 1/16/2014 The ...
- 转:Top 10 Algorithms for Coding Interview
The following are top 10 algorithms related concepts in coding interview. I will try to illustrate t ...
- Top 10 Algorithms of 20th and 21st Century
Top 10 Algorithms of 20th and 21st Century MATH 595 (Section TTA) Fall 2014 TR 2:00 pm - 3:20 pm, Ro ...
- Top 10 Free Wireless Network hacking/monitoring tools for ethical hackers and businesses
There are lots of free tools available online to get easy access to the WiFi networks intended to he ...
随机推荐
- 【前端攻略】最全面的水平垂直居中方案与flexbox布局
最近又遇到许多垂直居中的问题,这是Css布局当中十分常见的一个问题,诸如定长定宽或不定长宽的各类容器的垂直居中,其实都有很多种解决方案.而且在Css3的flexbox出现之后,解决各类居中问题变得更加 ...
- 如何用Perl对Excel的数据进行提取并分析
巡检类工作经常会出具日报,最近在原有日报的基础上又新增了一个表的数据量统计日报,主要是针对数据库中使用较频繁,数据量又较大的31张表.该日报有两个sheet组成,第一个sheet是数据填写,第二个sh ...
- [java] 更好的书写equals方法-汇率换算器的实现(4)
[java] 更好的书写equals方法-汇率换算器的实现(4) // */ // ]]> [java] 更好的书写equals方法-汇率换算器的实现(4) Table of Content ...
- chrome浏览器的跨域设置——包括版本49前后两种设置
做前后分离的webapp开发的时候,出于一些原因往往需要将浏览器设置成支持跨域的模式,好在chrome浏览器就是支持可跨域的设置,网上也有很多chrome跨域设置教程.但是新版本的chrome浏览器提 ...
- centos-5.5安装vmvare tools
centos-5.5安装vmvare tools 虚拟机管理,安装tools 找到VMwareTools压缩包 解压到Desktop,桌面 终端进入桌面 执行程序# ./vmware-install. ...
- Sublime Text 使用介绍、全套快捷键及插件推荐
开篇:如果说Notepad++是一款不错Code神器,那么Sublime Text应当称得上是神器滴哥.Sublime Text最大的优点就是跨平台,Mac和Windows均可完美使用:其次是强大的插 ...
- Python字典实现分析
背景介绍 最近使用Python开发项目为主,当使用到字典时感觉非常方便实用.那么好奇心就驱使我要搞清楚字典是怎么实现的.为了真正的搞清楚字典的实现就不得不使用C语言来实现一遍,为此我查了一些资料现在总 ...
- 多步骤多分步的组件StepJump
最近的工作在做一个多步骤多分步的表单页面,这个多步骤多分步的意思是说这个页面的业务是分多个步骤完成的,每个步骤可能又分多个小步骤来处理,大步骤之间,以及小步骤之间都是一种顺序发生的业务关系.起初以为这 ...
- scikit-learn一般实例之一:保序回归(Isotonic Regression)
对生成的数据进行保序回归的一个实例.保序回归能在训练数据上发现一个非递减逼近函数的同时最小化均方误差.这样的模型的好处是,它不用假设任何形式的目标函数,(如线性).为了比较,这里用一个线性回归作为参照 ...
- 7.6 数据注解特性--StringLength
StringLength attribute can be applied to a string type property of a class. EF Code-First will set t ...