// "static void main" must be defined in a public class.
public class Main {
public static void main(String[] args) {
String s = "";
int n = 10000;
for (int i = 0; i < n; i++) {
s += "hello";
}
}
}
func main() {
var s string = ""
var n int = 10000
for i := 0; i < n; i++ {
s += "hello"
}
}
https://go.dev/play/p/08cAfn65srV
// "static void main" must be defined in a public class.
public class Main {
public static void main(String[] args) {
String s = "Hello World";
char[] str = s.toCharArray();
str[5] = ',';
System.out.println(str);
}
}
func main() {
var s string = "Hello World"
str := []rune(s)
str[5] = ','
fmt.Println(s)
}
https://go.dev/play/p/F584GNYCUt2
Go Playground - The Go Programming Language
About the Playground The Go Playground is a web service that runs on go.dev's servers. The service receives a Go program, vets, compiles, links, and runs the program inside a sandbox, then returns the output. If the program contains tests or examples and n
go.dev
// "static void main" must be defined in a public class.
public class Main {
public static void main(String[] args) {
int n = 10000;
StringBuilder str = new StringBuilder();
for (int i = 0; i < n; i++) {
str.append("hello");
}
String s = str.toString();
}
}
func main() {
var n int = 10000
var sb strings.Builder
for i := 0; i < n; i++ {
sb.WriteString("hello")
}
var s string = sb.String()
fmt.Println(s)
}
[Go]Array and String - Implement strStr() (0) | 2022.04.04 |
---|---|
[Go] Array and string - Add binary (0) | 2022.04.03 |
Array and string - Introduction to String from Java to Go (0) | 2022.03.30 |
[Go] Array and string - Pascal's Triangle (0) | 2022.03.29 |
[Go] Array and String - Spiral Matrix (0) | 2022.03.29 |
댓글 영역