I was following some assistance that was provided by a codegym graduate person to a beginner and just stupidly copied and paste onto my assignment.
I literally dont have a clue about whats going on i feel like the whole subject wasnt explained properly and I have 0 understanding of what is this code used to?
what do we do here?
what we assigning to what? like what are all of those className.variableName combinations?
for now i do understand what a method is, what is a class and somewhat understand what is an object but i clearly can even recognize what is what in the code..
i can find the main method but to understand what an obejct is how to delcare it and what to assign to it?
Feeling very very very stupid
package en.codegym.task.jdk13.task04.task0402;
/*
Price of apples
*/
public class Solution {
public static void main(String[] args) {
Apple apple = new Apple();
apple.addPrice(50);
Apple apple2 = new Apple();
apple2.addPrice(100);
System.out.println("Apple price " + Apple.applePrice);
}
public static class Apple {
public static int applePrice = 0;
public static void addPrice(int applePrice) {
System.out.println("Parameter applePrice: " + applePrice);
System.out.println("Class variable Apple.applePrice before addition: " + Apple.applePrice);
Apple.applePrice = Apple.applePrice + applePrice;
System.out.println("Class variable Apple.applePrice after addition: " + Apple.applePrice);
}
}
}