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

  • SEARCH
  • Home
  • 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 6744947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:08:42+00:00 2026-05-26T12:08:42+00:00

This is a very odd, and quite specific question. Ultimately I am trying to

  • 0

This is a very odd, and quite specific question.

Ultimately I am trying to write a program convert that takes in java source, and transforms it such that it does not use (Among other things)

  • Arrays
  • Loops
  • User defined methods
  • If statements

This is a challenge that I set for myself, after my teacher told me that it was impossible to write a program without using these things.

I have most of these worked out, including function inlining and array substitution, however I cannot work out how to manage an if statement.

In C++ I’d use labels and gotos and maybe ?:, however Java does not support GOTO statements.

My question is this:
Given a section of code,

if(CONDITION)
{
   //More code in here
}

How can transform it such that it is functionally the same, however does not use the if keyword. Note that loop structures are also out of the question.

Given this, it would be easy to create else and else if statements.
However I am also unsure of how to create loops using this, as there is no GOTO statement and methods are out of the question.

Edit:
Please note that switches are also not allowed, nor is recursion (Ruled out by the fact that you cannot define user methods, and a recursive main function wouldn’t work with every program)
The ?: operator does not work for all situations. AFAIK you cannot call a void function with ?: as it wants to assign a value as part of its operation.

These conditions come from the IB Computer Science SL requires course, I am taking HL and as a class we were laughing at the ‘mastery’ factors for SL which include ‘if’ statements (And if fact 3/15 of them are ‘User defined methods with params and return types) The challenge is effectively to FAIL a mastery test in SL while still producing a program that functions correctly.

Answer: (By bdares)

String result = (CONDITION)?"0":"A";
try{
    Integer.parseInt(result);
    //Condition is true
} catch(NumberFormatException e){
    //Condition is false
}
  • 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-05-26T12:08:43+00:00Added an answer on May 26, 2026 at 12:08 pm
    if(A) {
        X();
    }
    else{
        Y();
    }
    

    can be converted to:

    A?X():Y();
    

    You can nest these all you want, or simply remove one side of the : and get a simple if. The conditionals are easy.

    If you want it to work for void methods, here’s a way:

    String result = A?"0":"A";
    try{
        Integer.parseInt(result);
        X();
    } catch(NumberFormatException e){
        Y();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very odd issue trying to run this quite simple C program
This is very odd and I'm wondering if anyone has any thoughts? I'm trying
I'm having this very odd issue while trying to serialize a class for logging
Ok, so this is very odd. I have a site that I am breaking
I've got this very odd bug that appears to be a quirk in Visual
This is quite odd, because I have a Character class that can access Frame.dimension.getWidth();
While reverse engineering I came around a very odd program that uses a calling
This is very odd. I've written a windows form tool in C# to return
Very odd problem as this is working perfectly on our old Classic ASP site.
I am doing very simple int division and I am getting odd results. 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.