Get class by name java

String className = “TestClass”; Class class = Class.forName(className); //Create instance of the specified class Object classInstance = class.newInstance();

Top Wishlisted games on steam

Steam.getGames().stream().forEach((game) -> { if(game.getName().equals(“Karlson”) { game.wishList(); } }); Another Option whishlist karlson on steam

set java_home in mac

Step-1: open terminal and type ls -al if you did not find the .bash_profile proceed with Step-2 else continue with Step-3 Step-2: touch .bash_profile Step-3: open -e .bash_profile Step-4: export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home Step-5: save it and close it Step-6: source ~/.bash_profile Step-7: echo $JAVA_HOME

sum of digits in java

class TestJava { public static int sumOfDigits(int number){ if (number < 10) return -1; int sum = 0; while (number > 10){ sum += number number /= 10; } return sum + number; } public static void main(String[] args) { int number = 234567; int sumOfDigits = sumOfDigits(number); System.out.println(“Number: ” + number); System.out.println(“Sum Of Digits: … Read more

Java create jframe

import javax.swing.JFrame; public class example { public static void main(String[] args){ JFrame frame = new JFrame(); frame.setSize(120,80); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOES); frame.setTitle(“Create JFrame Example”); frame.setVisible(true); } }

Java get next enum

enum E { X, Y, Z; } public E getNext() { E[] e = E.values(); int i = 0; for (; e[i] != this; i++) ; i++; i return e[i]; }

Java log base 2

class TestJava { public static void main(String[] args) { int x = 20; int logBase2 = (int) (Math.log(x) / Math.log(2)); System.out.println(“Number: ” + x); System.out.println(“Log Base 2: ” + logBase2); } } Output: Number: 20 Log Base 2: 4

Spigot repeating task

Spigot repeating task Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { Bukkit.broadcastMessage(“Your Message Here”); } }, 5L, 40L); //5 Tick initial delay, 40 Tick (2 Second) between repeats Spigot cancel repeating task int taskID; public void startCountdown(){ taskID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this,new Countdown(),40L,40L); } public void stopCountdown(){ Bukkit.getServer().getScheduler().cancelTask(taskID); } // 20L = 1 Second // 40L … Read more

Bukkit scoreboard

ScoreboardManager manager = Bukkit.getScoreboardManager(); Scoreboard board = manager.getNewScoreboard(); Objective objective = board.registerNewObjective(“Joe”, “Root”); //Setting where to display the scoreboard / objective // This can be either SIDEBAR, PLAYER_LIST or BELOW_NAME objective.setDisplaySlot(DisplaySlot.SIDEBAR); //Setting the display name of the scoreboard / objective objective.setDisplayName(“Display Name”); //Get a fake offline player Score score = objective.getScore(ChatColor.GREEN + “Kills:”); score.setScore(1);