1/* 2 * Copyright (c) 2022-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16function main(): void { 17 let str: String = "hello\nworld\n"; 18 let a: String = "abc"; 19 let b: String = "ace"; 20 let c: String = "abc"; 21 let n2: int = 41; 22 let n3: long = 42; 23 let n4: float = 43.43; 24 let n5: double = 44.44; 25 console.print(str); 26 console.println(); 27 console.print(str.charAt(2)); 28 console.println(); 29 console.print(str.length as int); 30 console.println(); 31 console.print(a.equals(b)); 32 console.println(); 33 console.print(a.equals(c)); 34 console.println(); 35 console.print(b.equals(c)); 36 console.println(); 37 console.print(n2); 38 console.println(); 39 console.print(n3); 40 console.println(); 41 console.print(n4); 42 console.println(); 43 console.print(n5); 44 console.println(); 45 46 let s1: String = "Why "; 47 let s2: String = "not"; 48 let sbr: StringBuilder = new StringBuilder(s1); 49 sbr.append(s2); 50 let quest: char = c'?'; 51 sbr.append(quest); 52 sbr.append(" Hm.\n"); 53 sbr.append(1); 54 sbr.append(c'\n'); 55 sbr.append(2.11); 56 console.print(sbr.toString()); 57 console.println(); 58} 59