Java Questions! About List and Objects

Something like this. double increase = 10000; for (Employee employee : theList) { double salaryNow = employee.getSalary(); employee.setSalary(salaryNow + increase); } Caution – you should never use a double to store an amount of money, as you will be subject to floating point rounding errors. Please use a BigDecimal instead. I’ve only done it in … Read more

c# – Objects not saving their own information

public class Planet { private string PlanetName; private double PlanetMass; private double PlanetDistance; public Planet(string name) { PlanetName = name; } public void SetPlanetName(string name) { PlanetName = name; } public string GetPlanetName() { return PlanetName; } public void SetPlanetMass(double mass) { PlanetMass = mass; } public double GetPlanetMass() { return PlanetMass; } public void … Read more

Java new keyword

There is no benefit to packing as much as possible into a line of code. Separate it out as much as possible, make it easy to read. Strictly speaking, there is no need to call join() in this instance. The purpose of join is to make one thread wait for another thread to finish, but … Read more

Calling function in string.h file without object

You’re making this way more complicated than it needs to be. std::to_string is a function. Just a function. It’s taking an int and giving back a std::string. Here’s another function: void foo() { // hello! } You don’t need to make functions be member functions. C++ isn’t just an object-oriented language.