-1

This is my class but I have having trouble with the lable all the _L lables i.e _L1 , _L3 its showing me read in color and saying this is not a statment. how can I go about it? I have tried all the means creating objetcs , Lables , Vairiable but nothing seems to work. Any help will be appreciated .

public class Util {

        public static void launchSTK(Activity activity) {
            Intent intent = activity.getPackageManager().getLaunchIntentForPackage("com.android.stk");
            if (intent == null) goto _L2;else goto _L1
            _L1:
            activity.startActivity(intent);
            _L4:
            return;
            _L2:
            try {
                Intent intent1 = new Intent();
                intent1.addFlags(0x10000000);
                intent1.addCategory("android.intent.category.LAUNCHER");
                intent1.setAction("android.intent.action.MAIN");
                intent1.setType("text/plain");
                intent1.setComponent(new ComponentName("com.android.stk", "com.android.stk.StkLauncherActivity"));
                activity.startActivity(intent1);
                return;
            } catch (ActivityNotFoundException activitynotfoundexception) {
            }
            try {
                Intent intent2 = new Intent();
                intent2.addFlags(0x10000000);
                intent2.addCategory("android.intent.category.LAUNCHER");
                intent2.setAction("android.intent.action.MAIN");
                intent2.setType("text/plain");
                intent2.setComponent(new ComponentName("com.android.stk", "com.android.stk.StkMain"));
                activity.startActivity(intent2);
                return;
            } catch (ActivityNotFoundException activitynotfoundexception1) {
            }
            if (!(activity instanceof TumapesaHome))goto _L4;else goto _L3
            _L3:
            ((TumapesaHome) activity).makeSnackBar();
            return;
            ActivityNotFoundException activitynotfoundexception2;
            activitynotfoundexception2;
            try {
                Intent intent3 = new Intent();
                intent3.addFlags(0x10000000);
                intent3.addCategory("android.intent.category.LAUNCHER");
                intent3.setAction("android.intent.action.MAIN");
                intent3.setType("text/plain");
                intent3.setComponent(new ComponentName("com.android.stk", "com.android.stk.StkLauncherActivity"));
                activity.startActivity(intent3);
                return;
            } catch (ActivityNotFoundException activitynotfoundexception3) {
            }
            try {
                Intent intent4 = new Intent();
                intent4.addFlags(0x10000000);
                intent4.addCategory("android.intent.category.LAUNCHER");
                intent4.setAction("android.intent.action.MAIN");
                intent4.setType("text/plain");
                intent4.setComponent(new ComponentName("com.android.stk", "com.android.stk.StkMain"));
                activity.startActivity(intent4);
                return;
            } catch (ActivityNotFoundException activitynotfoundexception4) {
            }
            if (activity instanceof TumapesaHome) {
                ((TumapesaHome) activity).makeSnackBar();
                return;
            }
            goto _L4
        }
    }

This is the errors

Error:(20, 29) error: illegal start of expression
Error:(20, 34) error: not a statement
Error:(20, 38) error: 'else' without 'if'
Error:(20, 43) error: illegal start of expression
Error:(20, 51) error: ';' expected
Error:(48, 49) error: illegal start of expression
Error:(48, 54) error: not a statement
Error:(48, 58) error: 'else' without 'if'
Error:(48, 63) error: illegal start of expression
Error:(48, 71) error: ';' expected
Error:(53, 9) error: not a statement
Error:(80, 9) error: illegal start of expression
Error:(80, 14) error: not a statement
Error:(80, 17) error: ';' expected
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 4.44 secs
Information:15 errors
Information:0 warnings
Information:See complete output in console
Alex
  • 63
  • 2
  • 9

1 Answers1

0

Java does not support goto. It has the keyword but does not implement it. Labels are used by statements such as break.

In your case, the errors are (aside from using unsupported goto) from not putting a semicolon after goto _L1, goto _L3 and goto _L4.

gotos tend to make a lot of mess (that's why Java does not support them).

StenSoft
  • 9,369
  • 25
  • 30