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 ...
随机推荐
- Objective-C中的语法糖
写这篇博客源于一个疑问:“WoK~, 这也行?!”.刚接触OC不久,今天做深浅拷贝的测试,无意中把获取NSArray的值写成了用下标获取的方式.当时把注意力放在了深浅拷贝的内存地址分析上了,就没太在意 ...
- Android随笔之——Android单元测试
在实际开发中,开发android软件的过程需要不断地进行测试.所以掌握Android的单元测试是极其重要的.您应该把单元测试作为Android应用开发周期的一部分,精心编写的测试可以在开发早起帮你发现 ...
- 关于Repository、IUnitOfWork 在领域层和应用服务层之间的代码分布与实现
本来早就准备总结一下关于Repository.IUnitOfWork之间的联系以及在各层中的分布,直到看到田园里的蟋蟀发表的文章:<DDD 领域驱动设计-谈谈 Repository.IUnitO ...
- 小菜学习Winform(六)剪切板和拖放复制
前言 在做winform项目的时候有时候会用到复制粘贴,在.net中提供了Clipboard类来操作剪切板,我们来看下. clipbrd.exe clipbrd是系统剪切板程序,但是在vista及以上 ...
- MVC, MVP, MVVM比较以及区别(下)
上一篇得到大家的关注,非常感谢.一些朋友评论中,希望快点出下一篇.由于自己对于这些模式的理解也是有限,所以这一篇来得迟了一些.对于这些模式的比较,是结合自己的理解,一些地方不一定准确,但是只有亮出自己 ...
- beego上传文件
html代码: <form id="fform" method="POST" enctype="multipart/form-data" ...
- 【SQLServer】DBHelper即C#数据库底层封装
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.C ...
- 【Java心得总结三】Java泛型上——初识泛型
一.函数参数与泛型比较 泛型(generics),从字面的意思理解就是泛化的类型,即参数化类型.泛型的作用是什么,这里与函数参数做一个比较: 无参数的函数: public int[] newIntAr ...
- spring笔记--通过注解(annotation)配置Bean
Spring能够在classpath下自动扫描,侦测和实例化具有特定注解的组件,这在Spring中成为组件扫描(Component scanning). 特定组件的注解包括: @Component:基 ...
- struts2学习笔记--OGNL表达式1
struts2标签库主要使用的是OGNL语言,类似于El表达式,但是强大得多,它是一种操作对象属性的表达式语言,OGNL有自己的优点: 能够访问对象的方法,如list.size(); 能够访问静态属性 ...