Hello, I am currently converting a C++ program into Java, but I cannot find the equivilant to UCHAR_MAX in Java. Does anyone know this?
C++ convert to Java?
Collapse
X
-
I have a statement,
ColorJitter::Co lorJitter() // Class constructor
{
int i; // Loop index
status = TRUE;
// Initialize jitter lookup table pointers
pirand = NULL;
pxrand = NULL;
pyrand = NULL;
noise = 1; // Set default noise level
if ((pirand = new int[C_TableSize]) == NULL)
{
status = FALSE;
return;
}
"status" as already been defined as a boolean in a previous class which this extends. I want to convert the if statement to Java but I am having trouble doing this.the reference "C_TableSiz e" has been declared in a previous class which this extends as well, it has declared:
public static final int C_TableSize = 1024;
Does anyone have any suggestions?Comment
-
What suggestion? A public static final int variable should be visible in a subclass.Originally posted by wiziousDoes anyone have any suggestions?
What exactly is the problem then? Don't say "it doesn't work" please. Give us
compilation and/or runtime error messages.
kind regards,
JosComment
-
well if I enter " if ((pirand = new int[C_TableSize]) == NULL) "
straight into Java, I get a " ')' expected" error at the line where the if statement is declared.
At first I tried rewriting it as a " if ((pirand = int[] C_TableSize == null)" statement instead, I get a ".class expected" error instead.
I think the most likely error is that I dont know what they are trying to do in the initial c++ code, so therefore its much harder for me to find a way to implement it in Java.
Regards,Comment
-
Try to change that NULL to lowercase null in that first version. Java doesn't knowOriginally posted by wiziouswell if I enter " if ((pirand = new int[C_TableSize]) == NULL) "
straight into Java, I get a " ')' expected" error at the line where the if statement is declared.
At first I tried rewriting it as a " if ((pirand = int[] C_TableSize == null)" statement instead, I get a ".class expected" error instead.
I think the most likely error is that I dont know what they are trying to do in the initial c++ code, so therefore its much harder for me to find a way to implement it in Java.
Regards,
anything about defined values but it does know what null (lowercase) is.
kind regards,
Jos
ps. it's rather hopeless to try to translate something from language A to language B
when you don't know what language A does ...Comment
-
*ahem*, slight correction: in Java an assignment token is an operator and anOriginally posted by LaharlThat won't work no matter how you tweak it, since Java doesn't support inline assignments. Just assign it before the if, then check if it's null.
assignment is an expression so you can do things like this:
[code=java]
if ((foo= new int[42]) != null)
[/code]
Of course some people don't find it readable; but it is still perfectly valid.
kind regards,
JosComment
Comment