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 ...
随机推荐
- 你需要知道的包管理器(Package Manager)
最近我花了一点时间关注了在不同系统之中所用到的包管理器(Package Manager) .最开始的时候,我是在使用Linux操作系统时,对这种工具以及它背后的想法深深迷恋住了:这真是自由的软件世界. ...
- Hibernate学习之——Hibernate环境搭建
之前在写关于安卓闹钟的教程,写了一半就没后一半了,其实自己也没做好,在校外实习,校内毕业实习又有任务,只能先放放了,等毕业实习结束之后,在继续安卓闹钟开发之旅,相信这个时间不会很久的.现在毕业实习用到 ...
- 如何在Windows Server 2008 上添加RD (远程桌面)会话主机配置的远程桌面授权服务器
在Windows Server系列的现存活跃产品中都默认的会开放两个随机附送的远程控制的授权,而一些特殊条件下我们需要启用多个远程终端连接,在购买了相应的授权之后,我们如何将配置好的服务器添加到远程桌 ...
- h5直播开发之旅总结
前言 关于直播,有很多相关技术文章,这里不多说. 作为前端,我们比较关心我们所需要的. 直播的大致流程: APP端调用摄像头 -> 拍摄视频 -> 实时上传视频 -> 服务器端获取视 ...
- 记录一则ORA-12154,ORA-12560解决过程
应用服务器:Windows Server 2008 R2 Enterprise 故障现象:项目侧同事反映应用服务器上的程序连接数据库报错:ORA-12560: TNS: 协议适配器错误 1.故障重现 ...
- String的按值传递,java传参都是传值
java中对象作为参数传递给一个方法,到底是值传递,还是引用传递? String和int参数传递是按值传递还是引用传递? 一道面试题目,String的传递: public String change( ...
- 关于jqGrig如何写自定义格式化函数将JSON数据的字符串转换为表格各个列的值
首先介绍一下jqGrid是一个jQuery的一个表格框架,现在有一个需求就是将数据库表的数据拿出来显示出来,分别有id,name,details三个字段,其中难点就是details字段,它的数据是这样 ...
- Windows 10 密钥分享
Windows 10 Technical Preview for Enterprise:KEY:PBHCJ-Q2NYD-2PX34-T2TD6-233PKhttp://technet.microsof ...
- sql语句优化SQL Server
MS SQL Server查询优化方法查询速度慢的原因很多,常见如下几种 1.没有索引或者没有用到索引(这是查询慢最常见的问题,是程序设计的缺陷) 2.I/O吞吐量小,形成了 ...
- C#基础-邮件发送
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...