View Problem

Perform an action a fixed number of times (FOR)

Display the string "Hello" five times like "HelloHelloHelloHelloHello"
ExpandDiskEdit
scala
// Using overloaded '*' operator (String-specific)
print("Hello" * 5)
ExpandDiskEdit
scala
List.range(0, 5) foreach { (_) => print("Hello") }
ExpandDiskEdit
scala
for (_ <- List.range(0, 5)) print("Hello")
ExpandDiskEdit
scala
// Lazy version
for (_ <- Stream.range(0, 5)) print("Hello")
ExpandDiskEdit
scala
dotimes(5, _ => print("Hello"))
ExpandDiskEdit
scala
(0 until 5) foreach { (_) => print("Hello") }
ExpandDiskEdit
scala
5 times { print("Hello") }
ExpandDiskEdit
java
for(int i=0;i<5;i++) {
System.out.print("Hello");
}

Submit a new solution for scala or java
There are 29 other solutions in additional languages (clojure, cpp, csharp, erlang ...)