Wednesday, October 7, 2015

Java 101 - 02 Comments, Objects, and Classes


Summary of last post(link here): We looked over the basic introduction of Java and some start on the syntax and specifics how Java should work. Here's the code that we ended up with to refresh your mind:
//This is the Myclass class naming
class MyClass{
//This is the main method we always need
public static void main(String []args){

}
//This is some random method we made, notice the capitalization rules.
public void thisMethodNotAllLowercase(){

}
}


In this post will go over commenting(which you've seen some from last post), Objects, and how classes are related to those Objects.

This is going to be a pretty simple a straight forward post about commenting in the Java programming language. Commenting in any language is useful if a few ways:

  1. If you are working on a crazy long project, comments will help you skim through what your lines are doing and refresh your mind quicker. That is both a time saver as well as a big life saver.
  2. If you are working with other team members and they need to know what you are doing, they can skim through your lines without sitting there forever trying to firgure out. That will save you and your team time, as well as get some work doneeeee.
  3. This sort of piggy backs with the first two, but if you decide to come back to it after a break then you won't have to worry about forgetting, it's all there!
Alright then, to the hows:
  • To comment just on one line, simply type "//" without the quotes.
  • To comment several rows simply start with "/*" and end with "*/" , also without the quotes.

//This is one line comment

/*
This
is
several
line
comment!
*/

/*
* This
* Just
* looks
* Prettier
*/

So, this basically ends it. Pretty simple eh? Now you can comment you can try creating your own code without having to remember everything by mind. Hope you learn something from this post and I'll try to post more soon.

*If you find a typo or error let me know! I'm human and I make silly mistakes too.

0 comments:

Post a Comment