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 ...
随机推荐
- Markdown编辑器入门
欢迎使用博客园的Markdown编辑器 前言 今天早上起来在Ubuntu下操作,所以不能使用Windows Live Writer.所以就直接使用博客园的后台编辑器,开始以为博客园出错了,怎么编辑都没 ...
- 【Java心得总结五】Java容器上——容器初探
在数学中我们有集合的概念,所谓的一个集合,就是将数个对象归类而分成为一个或数个形态各异的大小整体. 一般来讲,集合是具有某种特性的事物的整体,或是一些确认对象的汇集.构成集合的事物或对象称作元素或是成 ...
- IO多路复用之epoll总结
1.基本知识 epoll是在2.6内核中提出的,是之前的select和poll的增强版本.相对于select和poll来说,epoll更加灵活,没有描述符限制.epoll使用一个文件描述符管理多个描述 ...
- java删除文件夹
想删除本地一个项目目录,结果windows说路径太长,不能删除.于是试了试java删除.一切ok.以后一定要抓紧时间学python. /** * Created by rmiao on 4/21/20 ...
- 登陆后设置cookie的方法
public void SetCookie(string userName, string role,string cookieValueName) {FormsAuthentication.Form ...
- HTML5 canvas 捕鱼达人游戏
在线试玩:http://hovertree.com/texiao/html5/33/ html5利用canvas写的一个js版本的捕鱼,有积分统计,鱼可以全方位移动,炮会跟着鼠标移动,第一次打开需要鼠 ...
- C# 工作中遇到的几个问题
C# 工作中遇到的几个问题 1.将VS2010中的代码编辑器的默认字体“新宋体”改为“微软雅黑”后,代码的注释,很难对齐,特别是用SandCastle Help File Builder生成帮助文档 ...
- 一个简单的MVC实例及故障排除
Controller: public ActionResult Index() { string setting = "ApplicationServices"; var conn ...
- 增加线程异步发送消息的方法一(Thread)
@RequestMapping(value="order/updateOrder.do") public String updateOrder(HttpServletRequest ...
- 说说&和&&的区别
&和&&都可以用作逻辑与的运算符,表示逻辑与(and),当运算符两边的表达式的结果都为true 时,整个运算结果才为true,否则,只要有一方为false,则结果为false. ...