Agreed with MJRomeo here. Start off with the basics and work your way up. Not sure if this is the required text or not but the Absolute Java textbook is very good at explaining concepts. If you can problem solve and are dedicated to learning this language, then there will be no problems at all. It's very flexible in terms of what you can do - in the sense that there is no "one correct answer".
I would start off by viewing some basic online tutorials for Java (such as TutorialsPoint) which goes through from basic to advanced Java, and test out sample programs and try writing a few of your own using an IDE (Eclipse has been mentioned but there are others which you can use - I personally don't prefer Eclipse).
My main advice would be not to give up when it gets difficult and just try it! It takes a while to get used to but once you're used to it, it makes things much easier! Be careful and watch out how you type things - because one spelling mistake and the entire program starts to error, so it's important to watch out for that as you go. Lots of people find programming to be quite intimidating but it isn't once you grasp what is required. It involves creativity and planning
For example: A basic shop (cash/change) calculator which has 2 inputs required from the user - amount and cash. You can then think about well,
what calculations are required? what's needed? A simple format is like so:
Simple Shop System using one classCopy and paste this into a suitable IDE and see how this operates - as an example (name file Shop.java)
import java.util.Scanner; // A scanner is required for user input from the keyboard
public class Shop { // name of the .java file usually (e.g. Shop.java)
public static void main(String[] args) { // the main method - required
Scanner kb = new Scanner(System.in); // declare a Scanner so we can input via keyboard.
System.out.print("Total amount (in $): "); // ask the user for an input (amount of items)
double amount = kb.nextDouble(); // save the input to a variable called amount (cannot be int, could be a decimal value!)
System.out.print("Enter cash given (in $): "); // ask the user for another input (cash given by the customer to the attendant)
double cash = kb.nextDouble(); // save the input to a variable called cash of type double (cannot be int, could be a decimal!)
// calculate change required now
double change = cash - amount; // you could incorporate this in the println statement, but this works just as well
System.out.println("Change required: $" + change);
/* the plus sign is to indicate concatenation. Concatenation means joining together. We cant include it in the "" because change is not a string, it is a variable therefore it needs to be included in the print but as a variable, not a string. */
}
}
Expected output (using Netbeans)You could fix it up to remove the repetition of 9's, but that would be diving deeper.run:
Total amount (in $): 6.95
Enter cash given (in $): 13.20
Change required: $6.249999999999999
BUILD SUCCESSFUL (total time: 4 seconds)
All the best with this subject.