Java Data Types

Data types As we discussed in Java Variables when a variable is declared some part of memory is reserved. However, how much memory will be reserved depends upon the data type of the variable.  It means how much memory will be reserved and which type of data can be stored in reserved memory depending upon the … Read more

Save map in file java

Save map in file Map map = new HashMap(); Properties properties = new Properties(); for (Map.Entry entry : map.entrySet()) { properties.put(entry.getKey(), entry.getValue()); } properties.store(new FileOutputStream(“data.properties”), null); Load map from file Map mapFromFile = new HashMap(); Properties properties = new Properties(); properties.load(new FileInputStream(“data.properties”)); for (String key : properties.stringPropertyNames()) { mapFromFile.put(key, properties.get(key).toString()); }

Spigot spawn entity

World testWorld = Bukkit.getWorld(“Hello World!”); Location spawnLocation = new Location(testWorld, 0, 20, 0); Entity spawnedPig = testWorld.spawnEntity(spawnLocation, EntityType.PIG);

Divide with float java

//Just convert any one value to float float resultValue = (float)firstValue / secondValue;