Methods, control flow

posted by: Ms. Martin 11 September 2009 No Comment

We started the day with a quick warm-up exercise. We’ll often do this to make sure we’re all on the same page and get an opportunity to clear up any confusion.

Today’s topic was methods. I explained that methods are used to group together related statements and reduce redundancy. A method definition looks like this:

public static void () {

}

Just writing a method doesn’t do anything, though. We learned that Java programs are always run from the top of the main method down. So if a method is never called, it is never executed.

We used the jGRASP debugger to see control flow (the order in which statements are executed) in action. We discovered that computers have something called a call stack to keep track of which code is running currently and what will be run next. You can read more on the Wikipedia article on the topic.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>