Monday, August 22, 2016

JAVA 2 - Let it ...no!!!

So - we've successfully done our first program.  The next two sections will show you some useful tools to help you investigate when things go wrong.


Coding is such a tricky discipline, forget a semicolon, misspell a name or even use the wrong capitalisation, and bad things can happen.

Fear not though - the tools are on your side, and will try and help you when they can.

We're going to go back to our Hello World program from last time.

Problem 1

Now ... let's take the line,

System.out.println("Hello, World");

And remove that semicolon.  Oh yeah, we're going there!  Now save your project.

Immediately on your line, you can see a red cross next to your line ...


Likewise, if you go under your problems tab, you can see a breakdown of where you have an error ...


If you hover your mouse over the red cross on your code line, it'll even give you suggestions.

Replace the semicolon and save.  All those problems should go away.

Problem 2

Now - let's remove one of the brackets, and see what happens!


Problem 3

Does it really matter if the main function is static?  Let's remove it and find out ...


It doesn't seem to mind too much - not big red cross.  I guess it's okay ... so let's run it ...


The Console clearly objects, and makes it clear we need to change it to static.

Problem 4

What happens if our main method is private not public?


Again it doesn't seem to mind, so let's run it ...




Extension material

Try all kinds of ways to trash your Hello World and see how it generates errors.

2 comments:

  1. Class Names should start with PascalCasing - HelloWorldApplication.

    And Method names should be CamelCasing

    ReplyDelete


  2. The online lottery site you need to try.

    ผลสลาก Online casino gambling sites and online casinos. Gambling games that you can come to play fun at our online gambling games. This site has a lottery system that you have access to the services of our web site.


    In this day we have a lottery track of the teacher. I have updated the necklaces to have another track. And this time it has come to focus on 93 91. Which interested to try to grab a chance to get lucky for the day 16-12-60 this time you do not like to jump. In this way, the player who is interested in investing in online casino games with us, then the player can come to play casino games online with us. The player will not be disappointed. And today you will be more valuable when you join us. You will receive many bonuses and promotions. And when you come to the online gambling games on our site, you will receive many promotions. As you have never touched before, our website here. ตรวจหวย

    ReplyDelete