Not Yet Answered # Substituting a value in an array in JAVA

BestJewSinceJC 700 Discussion Starter yeungn

0

So what do you need help with? Have you tried it yet? Try it and post what you've got and we'll help.

0

hey thanks for your response. I'm fairly new with Java so I really appreciate your support! I'm working on a project for school that requires a method called createAllCombinations(int i)

The basic idea of the createAllCombinations method is to determine which combinations of constants from the domain, when substituted for each unique variable in the predicate list, make the predicate list true. A single combination of constants is called a possible solution. A possible solution that makes the predicate list true is called a solution. Substituting for “each unique variable” means that when we substitute a constant c for a variable v, we substitute c for all occurrences of v. If there exists at least one solution, then the createAllCombinations method returns true, otherwise it returns false.

Right now this is what I have so far!

```
protected boolean createAllCombinations(int i)
throws ParserException
{
System.out.println("Implement PredicateList.createAllCombinations");
if(variables.length == i)
if(checkToSeeIfTrue())
return true;
else
return false;
/** The variables to be used in this method:
*/
else
{
Constant value;
Constant[] arrayConstant;
Identifier var;
Constant constant;
/** Declaring the iterator and array of constants
*
*/
Iterator<Constant> itr = Domain.iterator();
arrayConstant = new Constant[variables.length];
/** Get all constants from the domain
*
*/
for(int n = 0; n > variables.length-1; n++)
{
value = itr.next();
arrayConstant[n] = value;
System.out.println(arrayConstant[n]);
}
/** Gather the Identifier to swap with the constant
*
*/
var = variables[i];
constant = arrayConstant[i];
i++;
createAllCombinations(i);
/**Substitute the constant we get from the domain for variables[i], wherever it occurs in the predicate list
*
*/
setVariableToValue(var, constant);
return true;
}
}
```

I'm wondering if I can substitute where I get the variable* (for example Bob) I would have to take all those values and replace it with a constant. I am not sure how to perform this in Java. Any pointers or hints?*

*Edited 7 Years Ago by yeungn*: n/a

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"

Here is the sample output that I ...

Hello All ...

Iam Getting An Error With try to excecute the stored procedure .

I have Have Sql database , the stored procedure like so :

```
USE [MPRS]
GO
/****** Object: StoredProcedure [dbo].[Search_Licenses_By_Number] Script Date: 26-Nov-16 8:06:52 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE ...
```

I don’t want at this stage work on a big separate project as I've already got plenty ...