https://www.hackerrank.com/challenges/reduced-string/problem He wants to reduce the string to its shortest length by doing a series of operations in which he selects a pair of adjacent lowercase letters that match, and then he deletes them. aaabccdd…
class Fruit { String color = "未确定颜色"; //定义一个方法,该方法返回调用该方法的实例 public Fruit getThis() { return this; } public void info() { System.out.println("Fruit方法"); } } public class Apple extends Fru…
SUPER可调用父类的构造方法,但要注意默认调用和参数调用. 同时,在继承类时,可以用SUPER调用其它非构造方法哟. class Test extends Object{ public Test(){ System.out.println("Test1 First thing"); } public Test(String welcome){ System.out.println("Test1 " + welcome); } protected void doSo…
引言 String可以说是在Java开发中必不可缺的一种类,String容易忽略的细节也很多,对String的了解程度也反映了一个Java程序员的基本功.下面就由一个面试题来引出对String的剖析. 1. String在源码里究竟是如何实现的,它有哪些方法,有什么作用? 从源码可以看出,String有三个私有方法,底层是由字符数组来存储字符串 public final class String implements java.io.Serializable, Comparable<String…
class A extends Exception{ A(){ super(); } A(String msg){ super(msg); } } class B extends A{ B(){ super(); } B(String msg){ super(msg); } } public class Test{ public static void main(String[] args){ try{ throw new B(); }catch(A e){ System.out.println…