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 7967511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:56:14+00:00 2026-06-04T06:56:14+00:00

I want to create dynamic conditional statement in java following are my expression in

  • 0

I want to create dynamic conditional statement in java
following are my expression in file,There are hundreds of expression and they keep on changing

0001|((condition1 == 100) && ((condition2 == 1) || (condition2 == 2) || (condition2 == 3)) && (condition3 > 74))
0002|((condition1 == 100) && ((condition2 == 1) || (condition2 == 2) || (condition2 == 3)) && (condition3 > 59) && ((condition4 == 3) || (condition5 > 30)))

These expression are hardcoded in my class.

if(condition1==100 && ((condition2 == 1) || (condition2 == 2) || (condition2 == 3))){

if(condition3>74){
return "0001"
}
if(condition3>59 && ((condition4 == 3) || (condition5 > 30))){
return "0002"
}

}

i want to create dynamic conditional statement like

first i have check for all expressions which have condition1==100
then for ((condition2 == 1) || (condition2 == 2) || (condition2 == 3))
then return value according to final condition

it is something like first DFS and then BFS

can some body can give me idea how to check first Depth and then Bredth First in java

  • 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-04T06:56:14+00:00Added an answer on June 4, 2026 at 6:56 am

    Your case is : You want define very many conditions and change it continous. You need to have a solution for change dynamically expression and define new condition.

    There are two solution for dynamic situation such as your case:

    1. Using Rule Engine. This has very benefit, you can see more information from http://java.sun.com/developer/technicalArticles/J2SE/JavaRule.html
      and you can see its open source implementation from here .
    2. Using Dynamic Language or Script Language and Script api.

    in second solution you have several choise. I writing some in following:

    • Groovy: A complete and wonderful script language. see http://groovy.codehaus.org/
    • Spring Expression Language: Spring solution for calling simple expression. see http://static.springsource.org/spring/docs/3.0.5.RELEASE/reference/expressions.html
    • BeanShell: A simple but wonderful script language.

    There are more dynamic language such as JRuby that you can see it by simple searching in web.
    You can read more information for Script api in java from here.

    Edited:

    For sample, you can use BeanShell Script Language as follwoing:

    First create a file with name test.bsh containg blow contents:

    if(variable_1 == 100 )
    {
       System.out.println("Sample condition checked and is true.");
    }
    else
    {
       System.out.println("Sample condition checked and is false.");
    }
    

    Second set variable_1 from java:

    import bsh.*;
    
    Interpreter bsh = new Interpreter ();
    bsh.set ("variable_1", 100);
    

    and in final call script as following:

     bsh.source (script);
    

    and result will be as following:

    Sample condition checked and is true.
    

    by this approach you can change test.bsh content without recompile or restart.

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

Sidebar

Related Questions

I want to create a dynamic Expression<Func<T,Y>> . Here is the code which works
I have less experience with Java Swing and I want to create a dynamic
I want to create dynamic java classes, I use a template to generate the
I am building a dynamic reporting feature for a client. They want to create
I am trying to create a conditional statement on my dynamic product pages on
I want to create dynamic tabPages in TabControl. In each tabPage I create dataGridView
I want to create dynamic number of thread which is depends on the database
I want to create a Dynamic aspx Page in current solution through code-behind..forexample i
this table i want to create job_id dynamic Jobs Title text Job Description text
I want to create PayPal button with dynamic price (depending from the item) and

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.