Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8703863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:57:43+00:00 2026-06-13T02:57:43+00:00

Consider this: public class Minesweeper extends MIDlet implements CommandListener { public static String error

  • 0

Consider this:

public class Minesweeper extends MIDlet implements CommandListener {
  public static String error = "";

  public void startApp() throws MIDletStateChangeException {

    try{
        int int = 5;
    } catch (Exception e) {
        error = e.toString();
    }
  }
}

int is an invalid name for an int, so surely the error should be caught and registered in error? (This error is there on purpose so I can catch it)

You’ve probably guessed it though, the error doesn’t seem to be caught, and the app stops with a java/lang/Error Unresolved compilation problem: syntax error on token 'int'....

What am I doing wrong.

(BTW, this was just a test so I knew I could catch errors properly, I’m obviously not going to use that code in a final version.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:57:44+00:00Added an answer on June 13, 2026 at 2:57 am

    Here is your problem – “int int = 5;” – you cannot use “int” as a variable name 😉

    You are trying to use a reserved word as a variable name. The compilation problem has nothing to do with your try-catch block working or not working, the compiler never gets that far.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this class: public class TestMap extends HashMap<String, Float> { public static void main(String[]
Consider this code: public class ShortDivision { public static void main(String[] args) { short
Consider this code: public static class PredefinedStrings { public const string Golf = Golfing;
Consider this code: public class Main { static String s = -; public static
Please consider this class: public static class Age { public static readonly string F1
Consider this class. public class DynamicField implements Comparable<DynamicField> { String title; int position; int
Consider this simple example - public class Person { private String name; private Date
please consider this code : 1)public static class MyClass 2){ 3) public static DateTime
Consider this code: package Prova; import java.util.ArrayList; public class Prova { private ArrayList<String> people;
Consider this snippet of code: public static class MatchCollectionExtensions { public static IEnumerable<T> AsEnumerable<T>(this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.