This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package animals; | |
public abstract class Animal { | |
private int bones; | |
private int age; | |
private String colour; | |
private int size; | |
private int weight; | |
private String diet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main; | |
public abstract class Animal { | |
public abstract void eat(); | |
public abstract void sleep(); | |
private String colour; | |
private int noOfLegs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main; | |
public class Blackjack { | |
public static int play(int hand1, int hand2) { | |
if (hand1 > 21 && hand2 > 21) { | |
return 0; | |
} else if (hand1 > 21) { | |
return hand2; | |
} else if (hand2 > 21) { | |
return hand1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let xhr = new XMLHttpRequest(); | |
xhr.open("GET", "api/movie/getAllMovies"); | |
xhr.onload = () => { | |
document.write(xhr.responseText); | |
} | |
xhr.send(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let xhr = new XMLHttpRequest(); | |
xhr.open("GET", "api/movie/getAllMovies"); | |
xhr.onload = () => { | |
document.write(xhr.responseText); | |
} | |
xhr.send(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main; | |
public class Hello { | |
public void print() { | |
System.out.println("Hello World!"); | |
} | |
public String returnHello() { | |
return "HelloWorld!"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); | |
// list = list.stream().filter(x -> x % 2 != 0 && x > 6 && x < 9).collect(Collectors.toList()); | |
// list = list.stream().map(x -> x * 10).collect(Collectors.toList()); | |
// System.out.println(list.stream().reduce((x, y) -> Math.max(x, y)).get()); | |
// list.stream().reduce(Math::max).get(); | |
System.out.println(list); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void oneToThousand() { | |
String[] units = { "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", | |
"Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen" }; | |
String[] tens = { "", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" }; | |
String[] hundreds = { "", "One Hundred", "Two Hundred", "Three Hundred", "Four Hundred", "Five Hundred", | |
"Six Hundred", "Seven Hundred", "Eight Hundred", "Nine Hundred" }; | |
for (int i = 0; i < 1000; i++) { | |
if (i > 99 && i % 100 > 19) { | |
System.out.println("" + hundreds[i / 100] + " " + tens[i / 10 % 10] + " " + units[i % 10]); | |
} else if (i > 99) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main; | |
public abstract class Animal { | |
private int numLimbs; | |
private int numEyes; | |
public Animal(int numLimbs, int numEyes) { | |
this.numLimbs = numLimbs; | |
this.numEyes = numEyes; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main; | |
public class DogShow { | |
public static String exclude(int place) { | |
StringBuilder output = new StringBuilder(); | |
for (int i = 1; i <= 100; i++) { | |
if (i != place) { | |
output.append(i); | |
if (i > 3 && i < 21) { | |
output.append("th"); |
OlderNewer