var x = 2;
function square(){
x = x * x;
}
var x = 2;
console.log(x) // 2
function square(){
x = x * x;
}
square();
console.log(x); // 4
var x = 2;
function square(y: number){
return y * y;
}
var x = 2;
console.log(x) // 2
function square(y: number){
return y * y;
}
square(x);
console.log(x); // 2
var square = function(x) {
return x * x;
}
setTimeout(function(){
console.log('A function
can be passed as an argument');
}, 1000);
(x, y) -> x + y;
int add(int x, int y) {
return x + y;
}
List<String> names =
Arrays.asList("Joe", "Jack", "James");
for (String name : names) {
System.out.println(name);
}
names.forEach(name -> System.out.println(name));
function(name){
System.out.println(name);
}
Map<String,Integer> map = new HashMap<>();
map.put("Atlanta, Georgia", 110);
map.put("Austin, Texas", 115);
map.put("Baltimore, Maryland", 105);
map.put("Birmingham, Alabama", 99);
map.put("Boston, Massachusetts", 98);
for (Map.Entry<String,Integer> e : map.entrySet()) {
System.out.println(e.getKey() + " => " +
e.getValue());
}
map.forEach((k, v) -> System.out.println(k + " => " + v));
List<String> myList =
Arrays.asList("a1", "a2", "b1", "c2", "c1");
List<String> myList =
Arrays.asList("a1", "a2", "b1", "c2", "c1");
myList
.stream()
.filter(s -> s.startsWith("c"))
.map(String::toUpperCase)
.sorted()
.forEach(System.out::println);
// C1
// C2