Beginners - 1 Basics

Here are some little things you should keep in mind after first installing Eclipse and making your first file.

Identifiers>

In your code, you must have seen a lot of bold colored words(for ex: public static void main). Those words (like public, class, static, etc.) are called 'Identifiers'. Basically, they are Java's vocab words which you cannot use as your own or in different ways.

Comments

Let's say that the only reason why you are making this Lincoln file is to show display the sentence 'A quote by Abe Lincoln: I am Abraham Lincoln'. You never write code without a purpose/requirement/function. So, to make sure you remember why we're writing this file, type the following:
 //display something about Abe 

And press enter. Did you notice that the color has changed? This is called a comment. We use comments to "explain the purpose of the program and describe processing steps". They don't effect our code so we can write as many comments as we want as long as we always start them off with a // for each line of code.
An alternative is to type to close it off. Try it out for yourself
 /* and write as many lines as you want (or just one)
 and then type */ 

White Space

When coding, Java doesn't give a shit about the white space or new lines you have in your code. Meaning, you can put hundreds of spaces and tabs between System.out.println("bla"); (i.e. System   .  out.println (   "bla"   );), and Java will interpret this the same as System.out.println("bla"). The only time a space will make a difference is when it's inside the ""  of the println("') statement. But, even though spaces mean nothing, you should always try to limit your spaces and maintain the same tabs that Java automatically generates (such as between { }) so that your code is readable and not annoying to the people who didn't write it.


More to come soon...
   
  
                           


No comments :

Post a Comment

Follow Me

If you like our content, feel free to follow me to stay updated.

Subscribe

Enter your email address:

We hate spam as much as you do.

Upload Material

Got an exam, project, tutorial video, exercise, solutions, unsolved problem, question, solution manual? We are open to any coding material. Why not upload?

Upload

Copyright © 2012 - 2014 Java Problems  --  About  --  Attribution  --  Privacy Policy  --  Terms of Use  --  Contact