Character类
package com.yuque.phil616.builtin;public class CharacterClass { char ch = 'a'; // the form of character in Unicode: // 这个字符是栈内存储存的 char uniChar = '\u039A'; // array of a character: char[] charArray ={ 'a', 'b', 'c', 'd', 'e' }; void testCharacterClass(){ Character ch = 'a'; /* * 下面的语句是标准的通过对象来创建一个字符类 * Character ch = new Character('a'); */ // code above is the usage of Character object // the original character of 'a' boxing to Character object chs Character chs = 'a'; }}
Math类
package com.yuque.phil616.builtin;public class MathClass { /** * Java提供了八种基本的数据类型 * 不过在开发过程中如果需要使用对象的时候,将基础的类进行封装boxing * 为了解决类的问题,java提供了如下类进行打包和拆包 * the relations between them look like this. * Object ->|---Character * |---Boolean * |---Number --->|---Byte * |---Short * |---Integer * |---Long * |---Float * |---Double */ Integer oi = 1; /** * for easy to develop and calculate,Java provide Math class. * the methods inside this class can help us to calculate special * math problems. * */ void mathFunc() { System.out.println("Sin of 90 degree " + Math.sin(Math.PI / 2)); System.out.println("cosine of 0 degree " + Math.cos(0)); System.out.println("tangent of 60 degree " + Math.tan(Math.PI / 3)); System.out.println("the arc-tangent of 1 " + Math.atan(1)); System.out.println("degrees of π/2 " + Math.toDegrees(Math.PI / 2)); System.out.println(Math.PI); }}
String类
package com.yuque.phil616.builtin;public class StringClass { /** * String class is a very usual class in java. * Before the examples, we need to know some computer * concepts. * Public areas and Heap * Public areas are the common ram space, it stored the * local variables and some strings. * Heap is a spacial area in ram. * Heap can stored objects with new operator. */ String str1 = "phil616"; String str2 = new String("phil616"); /** * str1 and str2 have the same context,however the java won't * think that. */ void testStrings(){ if(str1 == str2) { System.out.print("they are same"); }else{ System.out.print("they are not same"); } } /** * key word 'new' comes from C++, it will create a empty space in * heap to stored information. In this case, different object are * not the same thing though they have the same context. */ String str3 = new String("phil616"); //objects belongs different heap ares, so they are not same concept //of values /** * different from the String, the objects created by StringBuffer * or StringBuilder are allow to change and operate by its methods * The methods below will show the usage of this classes */ void StringBuilderTest(){ StringBuilder sb = new StringBuilder(10); sb.append("phil616.."); System.out.println(sb); sb.append("!"); System.out.println(sb); sb.insert(8, "Java"); System.out.println(sb); sb.delete(5,8); System.out.println(sb); } //When we are force to keep the thread secure, we have to use StringBuffer void StringBufferTest(){ StringBuffer sBuffer = new StringBuffer("github public website"); sBuffer.append("www"); sBuffer.append(".github"); sBuffer.append(".com"); System.out.println(sBuffer); }}