Solve real world problems with Java using multiple classes. Learn how to create programming solutions that scale using Java interfaces. Recognize that software engineering is more than writing code - it also involves logical thinking and design. By the end of this course you will have written a program that analyzes and sorts earthquake data, and developed a predictive text generator.
After completing this course, you will be able to:
1. Use sorting appropriately in solving problems;
2. Develop classes that implement the Comparable interface;
3. Use timing data to analyze empirical performance;
4. Break problems into multiple classes, each with their own methods;
5. Determine if a class from the Java API can be used in solving a particular problem;
6. Implement programming solutions using multiple approaches and recognize tradeoffs;
7. Use object-oriented concepts including interfaces and abstract classes when developing programs;
8. Appropriately hide implementation decisions so they are not visible in public methods; and
9. Recognize the limitations of algorithms and Java programs in solving problems.
10. Recognize standard Java classes and idioms including exception-handling, static methods, java.net, and java.io packages.

Reviews

MN

This nicely packaged course is learner centered. It engages the learner by enforcing practice through interesting exercises and quizzes. Kudos and Thumbs up to the team of great instructors

NS

Jun 16, 2016

Filled StarFilled StarFilled StarFilled StarFilled Star

Like all the modules of this Java specialization, the teachers are very good and the course reaches the objective of teaching the fundamentals of software design with an excellent didactic.

From the lesson

Java: Tools and Libraries for Everyone

As you reach the end of this series, you may wish to extend your Java experience to tools beyond those provided here. This module will cover some of the Java basic information that is needed to program without BlueJ or the edu.duke library. After completing this module, you will be able to: (1) write a main method to start a Java program in any programming environment, (2) use the “static” keyword to modify fields, (3) find alternative editors to use with Java, (4) use exceptions to debug your program and make it more robust, and (5) reference Java libraries that are necessary to read files without the edu.duke library.

Taught By

Robert Duvall

Owen Astrachan

Andrew D. Hilton

Susan H. Rodger

Transcript

You just learned about the main method, which is static. But what does that mean? It means that the method belongs to the class in general, but not any particular instance. To see what this means, let us first look at non-static fields for which there is one copy per instance of the class. As an example, suppose you were writing some banking software. You decide to make a class for a bank account and declare fields, the account balance and account number. These are great fields for a bank account class because each instance, that is each different bank account, has its own account number and its own balance. If you made three instances of this class to store the data for three accounts at your bank, they might look like this. We can see here how each instance has its own account number and balance. These fields are not static, they exist in each instance. Now suppose that as you write this software, you want to keep track of the next account number to assign. So that when you create a new account you know what number to give it. Creating an instance variable for this next account number, as shown here, would not work very well. Declaring this field makes each bank account have its own next account number, which is not really what you want. Lets see the problem this creates by looking at a constructor you might want to write. Which uses this next account number to initialize the account number of the bank account being constructed, and then increments that next account number as you see here. When you create the first bank account object, all the fields will start with 0 values. Then you will execute the code in the constructor. The first line will initialize this object's acctNum from this object's nextAcctNum, setting it to 0. Then, the next line will increment this object's nextAcctNum to 1. So far this behavior is fine, but you will see the problem when we create a second bank account object. This newly created object has its own copy of each field. Now when you execute the first line of the constructor, it uses the object's next account number to initialize this object's account number. Then you increment the account number inside the object to be 1. Oh no, you've ended up with two accounts with the same number! That will cause problems with your banking software. In fact, every account you create will be numbered 0. The problem here is the next account number is not a property of each different bank account, but rather something shared by all bank accounts. This is exactly what static is for. When something does not belong in each object of a particular type, but rather is shared by all objects of that type. Here you can see that we declared nextAcctNum to be static. Now that the nextAcctNum data is not stored in each bank account, but rather there is one copy that is shared by all of them. When you want to refer to a static field or method from outside of its class, you can do so by naming the class before the dot, since it does not belong inside of any particular object. For this field you can write BankAccount.nextAcctNum. So now you know a bit about static. For static fields there is only one copy, not one copy for each object instance. These tend to be much less common than instance fields. Often, you will want to describe objects in terms of properties that each instance of them have. However, there are times when static is appropriate, so it is good to know about. You can also declare static methods. With regular methods, you can think of them as being inside of each instance. But with static methods, as with static fields, you can think of them as being only one shared by all instances of the class. Static methods can only access static fields and other static methods of the class they belong to. However, they cannot directly access non-static fields or methods. If you wanted to access a non-static field or method from a static method, you would need to specify which object instance's field or method you would want to operate on with that object.TheFIeld or object.TheMethod.

Explore our Catalog

Join for free and get personalized recommendations, updates and offers.