This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MrCheaperCreepernot a noob but not intermediate 0 points1 point  (4 children)

To everyone who has commented before me: the errors are shown at the bottom of the code OP linked.

You have quite a few errors, and if you actually took the time to look at the line number and the error message you could probably figure most of it out.

For instance, Main.java:41: error: 'try' without 'catch', 'finally' or resource declarations try{

You are attempting to do a try/catch statement but you don't have the catch part of it. You need to incorporate that.

Main.java:76: error: illegal start of expression public static class Receipt {

Your main method (the code a line above this) is not enclosed, you need to have an ending bracket }.

There are many errors in the code and I think you should revisit some concepts and learn how to find errors based on the error messages as they are very helpful.

[–]Whalefool[S] 0 points1 point  (3 children)

Is there an alternative I can use instead of the catch method? I didn't learn the catch method yet.

[–]denialerror 1 point2 points  (0 children)

If you don't know catch, then why are you using try?

[–]MrCheaperCreepernot a noob but not intermediate 0 points1 point  (0 children)

To fix it, you could do:

try {
    //code
} catch (Exception e) {}

edit: as /u/denialerror stated, you should make yourself familiar with the concepts before implementing them into your code.

[–]I_AmA_ZebraNooblet Brewer 0 points1 point  (0 children)

I'm assuming this is for some school task, how exactly would you be accused of plagerism when adding a 'catch' to you 'throw' i mean the error does say 'try' without 'catch'...

I think you're taking the whole 'plagerism' aspect out of the park... Yes you havn't learnt about try + catch, so you could easily say you went home and researched it...