/* * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ function main(): void { let str: String = "hello\nworld\n"; let a: String = "abc"; let b: String = "ace"; let c: String = "abc"; let n2: int = 41; let n3: long = 42; let n4: float = 43.43; let n5: double = 44.44; console.print(str); console.println(); console.print(str.charAt(2)); console.println(); console.print(str.length as int); console.println(); console.print(a.equals(b)); console.println(); console.print(a.equals(c)); console.println(); console.print(b.equals(c)); console.println(); console.print(n2); console.println(); console.print(n3); console.println(); console.print(n4); console.println(); console.print(n5); console.println(); let s1: String = "Why "; let s2: String = "not"; let sbr: StringBuilder = new StringBuilder(s1); sbr.append(s2); let quest: char = c'?'; sbr.append(quest); sbr.append(" Hm.\n"); sbr.append(1); sbr.append(c'\n'); sbr.append(2.11); console.print(sbr.toString()); console.println(); }