So I was working on the project: A Simple Car Loan Paymen Calculator. In Learn Java - conditionals and control flow
and in the get unstuck video i was wondering why all the instance fields such as:
why are those instance fields declared inside of main() as opposed to the outer scope of the class were using to build this project?
Here is my noobish thinking please enlighten me if im wrong!
but my understanding is up to this point we use main() to actually depict what we want to run in our program. so if we wanted to create a reusable instance of an object we would define its class in the “outermost class” as i call it (sorry if thats wrong terminology lol).
so is the reason we write all the code in main in this project because we have the predetermined values that we want to use for the given example?
also would there be any concepts and circumstances where declaring all the instance fields inside of main as we do in this project be the most advantageous?
lastly - is this necessary because this is an if - statement? IE: with all if statements, do we need to write them in the main() method?
thanks all for input in advance!