Unfold Hierarchy number Tags Values

      JShell codes
        1  Examples
            1.1  Object
                1.1.1  string
String exampleString = "hello";
exampleString += " world";
"Contains e:"+ exampleString.contains("e") + "   length:" + exampleString.length();
                1.1.2  time
import java.util.Date;
Date exampleDate = new Date();
"current time:" + exampleDate.toString() + "     value:" + exampleDate.getTime();
                1.1.3  array
import java.util.Arrays;
double[] exampleArray =  new double[5];
for (int i=0; i
                1.1.4  list
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
List exampleList = new ArrayList<>();
exampleList.addAll(Arrays.asList("a", "b", "c", "d", "e"));
exampleList.toString();
            1.2  Expressions
                1.2.1  Numeric operations
                    1.2.1.1  e
Math.E
                    1.2.1.2  pi
Math.PI
                    1.2.1.3  absoluate
Math.abs(-5.611)
                    1.2.1.4  square root
Math.sqrt(9)
                    1.2.1.5  cubic root
Math.cbrt(27)
                    1.2.1.6  power
Math.pow(2,5)
                    1.2.1.7  power of e
Math.exp(2)
                    1.2.1.8  natural logarithm(base e)
Math.log(6)
                    1.2.1.9  common logarithm(base 10)
Math.log10(6)
                    1.2.1.10  cosine
Math.cos(0)
                    1.2.1.11  sine
Math.sin(9)
                    1.2.1.12  tangent
Math.tan(5)
                    1.2.1.13  arc tangent
Math.atan(-7.3)
                    1.2.1.14  arc cosine
Math.acos(0.5)
                    1.2.1.15  arc sine
Math.asin(0.3)
                    1.2.1.16  round up
Math.ceil(4.13)
                    1.2.1.17  round down
Math.floor(4.67)
                    1.2.1.18  round
Math.round(4.83)
                    1.2.1.19  random
Math.random()
                    1.2.1.20  maximum
Math.max(1,-3)
                    1.2.1.21  minimum
Math.min(1,-3)
                1.2.2  Strings operations
                    1.2.2.1  equals while ignore case
"Hello".equalsIgnoreCase("hello")
                    1.2.2.2  equals
"Hello".equals("hello")
                    1.2.2.3  replace first
"Hello World! World is yourself.".replace("World", "Feeling");
                    1.2.2.4  replace all
"Hello World! World is yourself.".replace(/World/g, "Feeling");
                    1.2.2.5  starts with
"Hello".startsWith("h")
                    1.2.2.6  end with
"Hello".endsWith("o")
                    1.2.2.7  subString
"Hello".substring(2, 5)
                    1.2.2.8  char at
"hello".charAt(2)
                    1.2.2.9  concat
"hello".concat(" world")
                    1.2.2.10  split
"1,2,3,4".split(",")
                    1.2.2.11  indexOf
"hello".indexOf("e")
                    1.2.2.12  lastIndexOf
"hello".lastIndexOf("l")
                    1.2.2.13  length
"hello".length()
                    1.2.2.14  toLowerCase
"Hello".toLowerCase()
                    1.2.2.15  toUpperCase
"Hello".toUpperCase()
                    1.2.2.16  contains
"Hello".contains("el")
                    1.2.2.17  trim
" Hello  ".trim()
                    1.2.2.18  isBlank
"  ".isBlank()
                    1.2.2.19  isEmpty
"".isEmpty()
                1.2.3  Boolean operations
                    1.2.3.1  list include
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
List exampleListC = new ArrayList<>();
exampleListC.addAll(Arrays.asList("a", "b", "c", "d", "e"));
String exampleStringC = "c";
exampleListC.contains(exampleStringC);
                    1.2.3.2  string match
// MyBox library paths should have been added in JShell environment
import mara.mybox.tools.StringTools;
String exampleStringM = "abc1233hello";
String exampleRegexM = "\\S*3{2,}\\S*";  
boolean exampleCaseInsensitiveM = true;
StringTools.match(exampleStringM,exampleRegexM,exampleCaseInsensitiveM);
                    1.2.3.3  string include
// MyBox library paths should have been added in JShell environment
import mara.mybox.tools.StringTools;
String exampleStringI = "abc1233hello";
String exampleRegexI = "3{2}";
boolean exampleCaseInsensitiveI = true;
StringTools.include(exampleStringI,exampleRegexI,exampleCaseInsensitiveI);
                    1.2.3.4  and/or/not
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
List exampleListB = new ArrayList<>();
exampleListB.addAll(Arrays.asList("a", "b", "c", "d", "e"));
String exampleStringB = "c";
exampleListB.contains(exampleStringB) && 
(exampleListB.size() >= 8 || exampleStringB.length() != 1 || !exampleStringB.startsWith("h"));
            1.3  Methods
                1.3.1  Area of circle
double circleAreaByDiameter(double diameter) {        
    double radius = diameter / 2;        
    return   Math.PI *  radius * radius ;        
}
circleAreaByDiameter(120) + circleAreaByDiameter(30)
                1.3.2  Round value
import java.math.BigDecimal;        
import java.math.RoundingMode;        
double scale(double v, int scale) {        
    BigDecimal b = new BigDecimal(v);        
    return b.setScale(scale, RoundingMode.HALF_UP).doubleValue();        
}    
scale(Math.PI, 3)
                1.3.3  Format number
import java.math.BigDecimal;        
import java.math.RoundingMode;        
double scale(double v, int scale) {        
    BigDecimal b = new BigDecimal(v);        
    return b.setScale(scale, RoundingMode.HALF_UP).doubleValue();        
}        
                                     
import java.text.DecimalFormat;        
String formatDouble(double data, int scale) {        
    try {        
        String format = "#,###";        
        if (scale > 0) {        
            format += "." + "#".repeat(scale);        
        }        
        DecimalFormat df = new DecimalFormat(format);        
        return df.format(scale(data, scale));        
    } catch (Exception e) {        
        return e.toString();        
    }        
}        
                                     
double circleAreaByRadius(double radius) {        
    return   Math.PI *  radius * radius ;        
}        
                                     
formatDouble(circleAreaByRadius(273.4), 4)
                1.3.4  Format date
import java.util.Date;
import java.util.TimeZone;
import java.text.SimpleDateFormat;

String DatetimeFormat = "yyyy-MM-dd HH:mm:ss.SSS";

String datetimeToString(Date theDate, String format, TimeZone theZone) {
    if (theDate == null || theZone == null) {
            return null;
    }
    SimpleDateFormat formatter = new SimpleDateFormat(format);
    formatter.setTimeZone(theZone);
    String dateString = formatter.format(theDate);
    return dateString;
}

datetimeToString(new Date(), DatetimeFormat, TimeZone.getDefault());
                1.3.5  string match
import java.util.regex.Matcher;
import java.util.regex.Pattern;

boolean match(String string, String find, boolean isRegex,
            boolean dotAll, boolean multiline, boolean caseInsensitive) {
        if (string == null || find == null || find.isEmpty()) {
            return false;
        }
        try {
            int mode = (isRegex ? 0x00 : Pattern.LITERAL)
                    | (caseInsensitive ? Pattern.CASE_INSENSITIVE : 0x00)
                    | (dotAll ? Pattern.DOTALL : 0x00)
                    | (multiline ? Pattern.MULTILINE : 0x00);
            Pattern pattern = Pattern.compile(find, mode);
            Matcher matcher = pattern.matcher(string);
            return matcher.matches();
        } catch (Exception e) {
            return false;
        }
}

match("Hello1233World", "\\S*3{2,}\\S*", true, true, true, true);
                1.3.6  string include
import java.util.regex.Matcher;
import java.util.regex.Pattern;

boolean include(String string, String find, boolean caseInsensitive) {
        if (string == null || find == null || find.isEmpty()) {
            return false;
        }
        try {
            int mode = (caseInsensitive ? Pattern.CASE_INSENSITIVE : 0x00) | Pattern.MULTILINE;
            Pattern pattern = Pattern.compile(find, mode);
            Matcher matcher = pattern.matcher(string);
            return matcher.find();
        } catch (Exception e) {
            return false;
        }
    }

include("Hello1233World", "3{2}", true);

* Links and controls may be unresponsive when html page is editable.