stringbuilder

2020年最新整理-Java面试题大全

梦想的初衷 提交于 2020-01-11 04:46:43
发现网上很多Java面试题都没有答案,所以花了很长时间搜集整理出来了一套Java面试题,希望对大家有帮助哈~ 阅读本文预计需要12分钟 打算这几天每天更新15~20题。(这样有助于你们阅读和理解!)我们先从简单的开始 1. JDK 和 JRE 有什么区别? JDK:Java Development Kit 的简称,java 开发工具包,提供了 java 的开发环境和运行环境。 JRE:Java Runtime Environment 的简称,java 运行环境,为 java 的运行提供了所需环境。 具体来说 JDK 其实包含了 JRE,同时还包含了编译 java 源码的编译器 javac,还包含了很多 java 程序调试和分析的工具。简单来说:如果你需要运行 java 程序,只需安装 JRE 就可以了,如果你需要编写 java 程序,需要安装 JDK。 2. == 和 equals 的区别是什么? == 解读 对于基本类型和引用类型 == 的作用效果是不同的,如下所示: 基本类型:比较的是值是否相同; 引用类型:比较的是引用是否相同; 代码示例: String x = "string"; String y = "string"; String z = new String("string"); System.out.println(x==y); // true System.out

java语言下的应用

若如初见. 提交于 2020-01-09 18:42:45
package com . huawei . csb . portal . cbcconnectservice . model ; import java . util . * ; import java . io . Serializable ; import com . fasterxml . jackson . annotation . JsonIgnoreProperties ; @JsonIgnoreProperties ( ignoreUnknown = true ) public class ConnectSuggestionInfo extends ArrayList < ConnectSuggestionInfoInner > implements Serializable { private static final long serialVersionUID = 1 L ; public ConnectSuggestionInfo ( ) { super ( ) ; } @Override public boolean equals ( Object o ) { if ( this == o ) { return true ; } if ( o == null || getClass ( ) != o . getClass ( ) ) { return

Java new String and new StringBuilder in heap behavior

元气小坏坏 提交于 2020-01-09 11:29:47
问题 Does the String pool reside on the heap? If yes, are String literals eligible for garbage collection? When using new String("abc") , we know that it creates an object on the heap and places the String literal in the String pool. So my 2nd question is: Does new StringBuilder("abc") behave the same way as new String("abc") ? If yes, how does StringBuilder manipulate the String literal inside the String pool? 回答1: You are confusing compile time, load time, and runtime. A string literal is added

Why doesn't StringBuilder have IndexOf method?

混江龙づ霸主 提交于 2020-01-09 10:35:54
问题 I understand that I can call ToString().IndexOf(...), but I don't want to create an extra string. I understand that I can write a search routine manually. I just wonder why such a routine doesn't already exist in the framework. 回答1: Unfortunately, many of the methods implemented for String could have been implemented for StringBuilder but that was not done. Consider using extension methods to add what you care about. 回答2: I know this is an old question, however I have written a extension

Difference between string and StringBuilder in C#

安稳与你 提交于 2020-01-08 11:27:07
问题 What is the difference between string and StringBuilder ? Also, what would be some examples for understanding? 回答1: A string instance is immutable. You cannot change it after it was created. Any operation that appears to change the string instead returns a new instance: string foo = "Foo"; // returns a new string instance instead of changing the old one string bar = foo.Replace('o', 'a'); string baz = foo + "bar"; // ditto here Immutable objects have some nice properties, such as they can be

Difference between string and StringBuilder in C#

风流意气都作罢 提交于 2020-01-08 11:26:11
问题 What is the difference between string and StringBuilder ? Also, what would be some examples for understanding? 回答1: A string instance is immutable. You cannot change it after it was created. Any operation that appears to change the string instead returns a new instance: string foo = "Foo"; // returns a new string instance instead of changing the old one string bar = foo.Replace('o', 'a'); string baz = foo + "bar"; // ditto here Immutable objects have some nice properties, such as they can be

Modify non immutable object, java

天涯浪子 提交于 2020-01-07 09:56:08
问题 I am confused with this example : StringBuilder a = new StringBuilder("abcde"); String subStr = a.substring( a.indexOf("a") , a.indexOf("c") ); int leng = a.length(); char ch = a.charAt(4); System.out.println( subStr + " " + leng + " " + ch); //the result will be : subStr = abc , leng = 5 ch = e My question is : Why ch = e and it doesn't create an Exception ? My thinking: I have one StringBuilder, a non immutable object and if I use a method on the object it will return me a new value of the

xposed云闪付免签支付系统源码

微笑、不失礼 提交于 2020-01-06 12:32:31
云闪付免签支付系统是通过xposed框架Hook云闪付,自动生成指定金额的支付二维码,支付完成后App监控云闪付支付成功信息,实现自动回调。 支持H5,支持自动回调,支持多客户端多卡轮询。 xposed云闪付免签支付系统核心源码——生码二维码代码: public static void GenQrCode(final String paramString1, final String paramString2, final String bankName, final String bankNo) { new Thread(new Runnable() { public void run() { try { Object localObject1 = paramString2; Object localObject2 = new BigDecimal(paramString1); localObject2 = ((BigDecimal) localObject2).setScale(2, RoundingMode.HALF_UP).toPlainString().replace(".", ""); Object localObject3 = new StringBuilder(); ((StringBuilder) localObject3).append("https://pay

Java - Replace a character in a string

雨燕双飞 提交于 2020-01-06 03:19:46
问题 don't think I haven't searched online for an answer. Why is it giving me outofbounds error? I have two 6-chars long strings. One is "daniel" and another is "------". User enters a character. Loop goes through the "daniel" string and checking char by char is they match with the user input. If it matches, it should replace the guessed char with the one in "------". So if you input 'a' it should output "-a----" and the loop continues. Next if you enter 'e' it should output "-a--e-" etc. Code

xposed云闪付免签支付系统源码

痴心易碎 提交于 2020-01-04 11:16:04
云闪付免签支付系统是通过xposed框架Hook云闪付,自动生成指定金额的支付二维码,支付完成后App监控云闪付支付成功信息,实现自动回调。 支持H5,支持自动回调,支持多客户端多卡轮询。 xposed云闪付免签支付系统核心源码——生码二维码代码: public static void GenQrCode(final String paramString1, final String paramString2, final String bankName, final String bankNo) { new Thread(new Runnable() { public void run() { try { Object localObject1 = paramString2; Object localObject2 = new BigDecimal(paramString1); localObject2 = ((BigDecimal) localObject2).setScale(2, RoundingMode.HALF_UP).toPlainString().replace(".", ""); Object localObject3 = new StringBuilder(); ((StringBuilder) localObject3).append("https://pay