Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 01-30-2005, 12:43 AM   #1 (permalink)
freesoft_2000
Code Monkey
 
Join Date: Oct 2004
Posts: 51
freesoft_2000 is on a distinguished road
Question GoTo

Hi everyone,

I need to use something in java that is similar to the C language goto statement.

This is what i have in a function

Code:
public int ret()
{

if
{
//something
//something

//This is the part where i need to jump to the end of the
//function and not exit the function
}

//This is the part i need to jump to

//some more code
//some more code
}
Is there a way in which the above problem can be got around. Usually in the C language i would use the goto statement. I can't use a labeled break here as there is no loop in my program.

I hope someone can help me this problem

Thank You

Yours Sincerely

Richard West
freesoft_2000 is offline   Reply With Quote
Old 01-30-2005, 07:29 AM   #2 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 285
technobard is on a distinguished road
It sounds like you just need a nested if..else. So inside your main "if", you'd have something like:
Code:
if (bypass == false) {   //whatever condition you use
    // keep executing code
    //....
} else {  //bypass is true
    // skip earlier code and continue here
    // ....
}
__________________
It takes 2 points to draw a straight line, but at least 3 points to draw a conclusion.
technobard is offline   Reply With Quote
Old 01-30-2005, 10:15 AM   #3 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,161
Belisarius is on a distinguished road
Java actually defines the keyword "goto", but I think it was a practical joke on the part of the language spec team . . .
__________________
GitS
Belisarius is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with a little CompSci homework? Dante Java 9 04-23-2003 08:46 AM
Installing and using CMUgraphics library. Valmont Standard C, C++ 12 03-29-2003 08:39 AM


All times are GMT -8. The time now is 08:22 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting