Compiler errors

  • (2 Pages)
  • +
  • 1
  • 2

25 Replies - 5280 Views - Last Post: 10 July 2012 - 09:26 AM Rate Topic: ***-- 3 Votes

#16 GregBrannon   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2250
  • View blog
  • Posts: 5,340
  • Joined: 10-September 10

Re: Compiler errors

Posted 10 July 2012 - 07:55 AM

View Postkahem42, on 10 July 2012 - 08:07 AM, said:

would someone allow me to send them all the project files and correct the errors would be very grateful

Haha! Good one.
Was This Post Helpful? 1
  • +
  • -

#17 kahem42   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 10-July 12

Re: Compiler errors

Posted 10 July 2012 - 08:38 AM

Its not Homework or anything its just a Time killer
Was This Post Helpful? 0
  • +
  • -

#18 SwiftStriker00   User is offline

  • No idea why my code works
  • member icon

Reputation: 440
  • View blog
  • Posts: 1,618
  • Joined: 25-December 08

Re: Compiler errors

Posted 10 July 2012 - 08:45 AM

View Postkahem42, on 10 July 2012 - 11:38 AM, said:

Its not Homework or anything its just a Time killer


Thats not the point. The point is *you* are supposed to be learning and trying to fix the code. We don't give solutions, we help and teach. We gave you a few to get you started. Half your errors are the same as the ones we already fixed. I also gave you a link to a tutorialon how to dissect these errors and easily fix them.

Make a serious attempt at fixing the code, then if you get stuck. Comeback explain where you are stuck and what you have tried. Then we will be happy to help.
Was This Post Helpful? 0
  • +
  • -

#19 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 12350
  • View blog
  • Posts: 20,984
  • Joined: 19-March 11

Re: Compiler errors

Posted 10 July 2012 - 08:46 AM

Yes, but it's your time you're killing. Not mine.

Fixes:
First, correct your indentation
Second, make sure your braces are matched
Third, review the syntax of constructions you're not clear on, like try/catch/finally, and repair those
Fourth... profit!
Was This Post Helpful? 0
  • +
  • -

#20 kahem42   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 10-July 12

Re: Compiler errors

Posted 10 July 2012 - 09:02 AM

1) i cant write java or c++ i can simply edit something of them and change things around i downloaded a source code and began to edit when it came to compiling i found errors in files i didn't change im not planing on making any money from this just to gain experience
Was This Post Helpful? 0
  • +
  • -

#21 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: Compiler errors

Posted 10 July 2012 - 09:05 AM

Then perhaps you're doing too much. Pick a simpler project and write it from scratch. Look at intro classes for assignments. We're hear to help members with their problems, not with correcting code they copy/pasted. If you don't want to learn how to code, that's fine. Just don't expect others to correct things for you.
Was This Post Helpful? 0
  • +
  • -

#22 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 12350
  • View blog
  • Posts: 20,984
  • Joined: 19-March 11

Re: Compiler errors

Posted 10 July 2012 - 09:10 AM

If you want to gain experience, you'll get it by debugging your own code. You won't get it by watching someone else debug it for you, any more than you can learn to hit a target by watching someone practice archery.

Learn the syntax, fix your code so you can see where you're bollixing the syntax, fix the syntax.

At its simplest, a try/catch block looks something like this:

try {
  dangerousOperation();  // do something that might throw an exception
}
catch (UnmetExpectationException fse)   // catch a particular exception
{  // deal with the situation here
  logger.log("Operation failed: expected something, got something else.");
}

Was This Post Helpful? 0
  • +
  • -

#23 kahem42   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 10-July 12

Re: Compiler errors

Posted 10 July 2012 - 09:16 AM

can you only have one operation?
Was This Post Helpful? 0
  • +
  • -

#24 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: Compiler errors

Posted 10 July 2012 - 09:18 AM

One operation for what?
Was This Post Helpful? 0
  • +
  • -

#25 SwiftStriker00   User is offline

  • No idea why my code works
  • member icon

Reputation: 440
  • View blog
  • Posts: 1,618
  • Joined: 25-December 08

Re: Compiler errors

Posted 10 July 2012 - 09:18 AM

No, you can have as much code as you want in a try block. However if any of those operations throws an exception, it will stop and skip to the catch statement.
Was This Post Helpful? 0
  • +
  • -

#26 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 12350
  • View blog
  • Posts: 20,984
  • Joined: 19-March 11

Re: Compiler errors

Posted 10 July 2012 - 09:26 AM

As I said before, you should minimize the code in the try block. Try blocks are for special handling. The point is to catch a particular problem and deal with it, that's easiest when you minimize the contents of the try block and catch specific Exceptions.

There are no language-based limitations to the scope of a try block. This is legal, but not recommended:

public static void main(String[] args)
{
  try{
     JFrame frame = new JFrame();
     // put stuff in the frame  
     // turn the user loose on that stuff
     // get some data from the user
     // process the data - the problem you know about is here
     // write processed data to a file
     // exit
  }
  catch(Exception e)
  { 
     
     e.printStackTrace();
  }
  // exit the program
}



This can even work, as long as you, the programmer, are the one running it and can debug it.

If you expect the program to be used by anyone else, you're dropping your failures in their lap, and that's bad programming.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2