toString() toArray() 等to方法
1.toString()方法
toString()方法是把对象转成String类型的
println(Ojbect object)的方法他会自动调用被打印对象的toString方法,所以其实你的
System.out.println(s2.toString());
System.out.println(s2);
你做的第一个通用查询,小龙哥用的array.toString()把这个json字符串打出来了
2.toArray()方法
public static void main(String[] args) {
ArrayList<Object> al = new ArrayList<Object>();
al.add(new StringBuffer("a"));
al.add(new StringBuffer("b"));
al.add(new StringBuffer("c"));
al.add("lcy");
al.add(10086);
System.out.println("al中元素:" + al);
// 获得数组:这个数组就是C语言中的那种数组(这个数组能装Object类型的元素)
Object ia[] = al.toArray();
// 遍历数组,转的这个数组有length这个方法
for (int i = 0; i < ia.length; i++) {
System.out.println(ia[i] + " ");
}
}

——————————————
ArrayList的toArray()方法
JSONObject的fromObect()静态方法
JSONArray的fromObject()静态方法
Object的toString()方法
toString() toArray() 等to方法的更多相关文章
- 集合转数组的toArray()和toArray(T[] a)方法
参考:集合转数组的toArray()和toArray(T[] a)方法 1.ArrayList的toArray ArrayList提供了一个将List转为数组的一个非常方便的方法toArray.toA ...
- LINQ to Entities 不识别方法“System.String ToString()”,因此该方法无法转换为存储表达式。
var data = DataSource.Skip(iDisplayStart).Take(iDisplayLength).Select(o => new { MatNR = o.MatNR, ...
- java数组、java.lang.String、java.util.Arrays、java.lang.Object的toString()方法和equals()方法详解
public class Test { public static void main(String[] args) { int[] a = {1, 2, 4, 6}; int[] b = a; in ...
- Exception 的 toString() 方法和 getMessage() 方法的区别
Exception 的 toString() 方法和 getMessage() 方法的区别: 在开发的过程中打印错误日志时尽量使用e.toString() 方法, 因为当错误为空指针时 e.getMe ...
- Object、String、数组的 toString() 方法和 equals() 方法及java.util.Arrays
public class Test { public static void main(String[] args) { int[] a = {1, 2, 4, 6}; int[] b = a; in ...
- LINQ to Entities 不识别方法"System.String ToString()",因此该方法无法转换为存储表达式 的解决方法
一.案例1,及解决方案: "LINQ to Entities 不识别方法"System.String ToString()",因此该方法无法转换为存储表达式." ...
- List中toArray()的使用方法
当我们需要把一个链表中的元素放入数组时,jdk给我们提供了一种方法,也即运用toArray(),方法的使用如下: public class Test { public static void main ...
- Java 异常Exception e中e的getMessage()和toString()以及 e.printStackTrace();方法的区别
Exception e中e的getMessage()和toString()方法的区别: 示例代码1: public class TestInfo { private static String ...
- Object.prototype.toString.call(obj)使用方法以及原理
这几天看vue-router的源码 发现了Object.prototype.toString.call()这样的用法,当时以为这就是转成字符串的用的,但是越看越觉得不太对劲,赶紧查查资料,一查才知道没 ...
随机推荐
- 雷林鹏分享:Ruby 安装 - Unix
Ruby 安装 - Unix 下面列出了在 Unix 机器上安装 Ruby 的步骤. 注意:在安装之前,请确保您有 root 权限. 下载最新版的 Ruby 压缩文件.请点击这里下载. 下载 Ruby ...
- 20161210xlVBA一行数据转为四行
Sub NextSeven_CodeFrame() '应用程序设置 Application.ScreenUpdating = False Application.DisplayAlerts = Fal ...
- (GoRails )使用Vue.js制作拖拉list功能(v1-4) gem 'acts_as_list'(自动排列顺序)
系列视频: use Vue.js to build the drag and drop support for the list themselves the cards that are under ...
- hdoj3652 B-number
题意:给出n,问1-n中有13且能整除13的数数量. 就是hd3555和codeforces beautiful number的合成版.dp记录待填长度,是否带有13,前面数的模13余数,前一个数是k ...
- Confluence 6 LDAP 成员结构设置
用户组成员属性(Group Members Attribute) 这个属性字段将在载入用户组成员的时候使用.例如: member 用户成员属性(User Membership Attribute) 这 ...
- ORACLE常见方法使用(转)
1.DBMS_LOB包的使用 2.如何释放DBMS_LOB.CREATETEMPORARY的空间 3.oracle数组
- spring--mvc用戶注册用户名验重
spring--mvc用戶注册用户名验重 注册是验证用户名是否重复.post方法,当表单的用户名文本框失去焦点时,由ajax方法指定,进行@RequestMapping指定的url提交时调用的方法. ...
- OC MRC之计数器的基本操作(代码分析)
/* 1.方法的基本使用 1> retain :计数器+1,会返回对象本身 2> release :计数器-1,没有返回值 3> retainCount :获取当前的计数器 4> ...
- PHP:第二章——PHP中的foreach语句
foreach语句提供了遍历数组的 <?php header("Content-Type:text/html;charset=utf-8"); $arr=array(&quo ...
- (C#基础)Linq学习理解
一遍学习基础,一遍练习打字,很多乐趣. 代码 using System; using System.Collections.Generic; using System.Linq; using Syst ...
