473,394 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

C++ convert to Java?

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?
Mar 15 '08 #1
8 1932
JosAH
11,448 Expert 8TB
Look at the static constants in the Character class. I think the one you
want is MAX_VALUE.

kind regards,

Jos
Mar 15 '08 #2
I have a statement,

ColorJitter::ColorJitter() // 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_TableSize" 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?
Mar 19 '08 #3
JosAH
11,448 Expert 8TB
Does anyone have any suggestions?
What suggestion? A public static final int variable should be visible in a subclass.
What exactly is the problem then? Don't say "it doesn't work" please. Give us
compilation and/or runtime error messages.

kind regards,

Jos
Mar 19 '08 #4
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,
Mar 19 '08 #5
JosAH
11,448 Expert 8TB
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,
Try to change that NULL to lowercase null in that first version. Java doesn't know
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 ...
Mar 19 '08 #6
Laharl
849 Expert 512MB
That 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.
Mar 19 '08 #7
JosAH
11,448 Expert 8TB
That 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.
*ahem*, slight correction: in Java an assignment token is an operator and an
assignment is an expression so you can do things like this:

Expand|Select|Wrap|Line Numbers
  1. if ((foo= new int[42]) != null) 
  2.  
Of course some people don't find it readable; but it is still perfectly valid.

kind regards,

Jos
Mar 19 '08 #8
Laharl
849 Expert 512MB
Huh, you learn something new every day. I'd figured they'd disallowed that to avoid the fun in C that you get with that when you forget that second =.
Mar 19 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jens Mueller | last post by:
Hi there, this is a Java-XML Question, so I am not sure whether this is the right place, haven't found anything better .... I try to convert a Java object to XML via SAX and let the FOP...
0
by: Chua Wen Ching | last post by:
Hi there, I had downloaded the Java Language Conversion Assistant 2.0 from http://msdn.microsoft.com/vstudio/downloads/tools/jlca/. I had installed it and it was suppose to integrate to...
3
by: Mike | last post by:
Hi, Does anyone know of reliable programs that convert C# to Java and viceversa? Thanks Mike
2
by: Barney | last post by:
I have to convert a Java app to .NET, i found and used the conversion tool which converts java to C#, but it only converted about 10% of it, how hard would it be to re-write the java app and keep...
0
by: NoSpamForMe | last post by:
I am currently a java programmer, with some knowledge of the C# language but very little knowledge about ASP.NET, and I am know wondering if someone can *translate* the java servlet code below to...
1
by: sachin | last post by:
hello everyone, i am trying to convert my XSL-FO to PDF file by using fop-0.20.5 by importing the following classes: import java.io.File; import java.io.IOException; import...
17
by: Terry Jolly | last post by:
New to C# ---- How do I convert a Date to int? In VB6: Dim lDate as long lDate = CLng(Date) In C#
3
by: GM | last post by:
Dear all, Could you all give me some guide on how to convert my big5 string to unicode using python? I already knew that I might use cjkcodecs or python 2.4 but I still don't have idea on what...
5
by: Jonathan Sachs | last post by:
I'm interested in experienced .Net developers' opinions about whether I should convert an existing Java program to J# or C#. I thought this was a no-brainer until I discovered that with the...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.