Jim Pouwels

Ranch Hand
+ Follow
since Feb 22, 2012
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jim Pouwels

A synchronous webservice call immediately results in a response containing the data you're requesting.

An asynchronous webservice call does not return the result in the first response. Either the client has to request the result later (f.e. using a requestId), or the server sends the result back to the client (f.e. using a callback address).
11 years ago
There's no possible way for us to provide you with a good answer to this question. There's no context what so ever.

What have you developed so far? What code do you have? What's your way of working?
11 years ago

for(int i = 0; i < size ; i++)
String str = scanner.next();
int x = Integer.parseInt(str,16);
String hexString = Integer.toHexString(x);
int y = Integer.parseInt(hexString,16);
byteArray[i] = (byte)y;

Your code looks a bit weird. You're mixing up values and representations of the values.

At this point you've got your correct int value. F.e. you typed 17 (of which you say it's a hex number). This int value now contains the value 23. Which is correct.

You can now store this value in your bytearray. And when you want to print it, you can use my code in order to represent it in a hex format.
11 years ago
That fixed the problem. Tnx!
11 years ago
I edited my reply.
11 years ago
When you print a value of the array, f.e. like this:

The value will be printed as a decimal. The value 0x58 in hex equals 88 in dec.

You can use:

11 years ago
Hi Guys,

I'm trying to get a simple servlet working in JBoss 7.

First, i got my servlet:

The CDI bean is just a simple POJO with one method (getGreeting()).

The problem is the web.xml in my war file. When I include one, the servlet is not available.


When I remove the web.xml from the WAR file, then the servlet becomes available.

Anyone encountered this issue?

11 years ago

Jesper de Jong wrote:To see why you can't convert a byte to a char implicitly, look at this example. What value would you expect the char to have?

So the issue is signed vs unsigned: possible loss of precision.

12 years ago

Manoj Kumar Jain wrote:Is it only the size that matters while passing/recieving the data ?
When you passing the short, while method is expecting the long type is fine because short is the type of int/long. so by implicite casting the program runs without any error.
but while you are passing the byte while method is expecting character is not correct because byte can't be cast in to a character.
So, this is not only the size that matters but also the type of data that you are passing. Instead of passing the short if you pass the character type to method and define the method like this

It will work fine because the char is of type Integer, so it can be cast to int type.

This just sounds incorrect to me. If a char is of type int ... and a byte can't be passed to a char, then you are saying that a byte isn't of type int. Aren't you?

Why does the following work then?

This whole typing story just sounds wrong. But maby i'm mistaking. I think it has everything to do with size.
12 years ago
Hi all,

I'm looking at literals and which literal I can implicitly assign to another type.

For example, the following works:

Because short (16 bit) fits into a long (64 bit).

But then why doesn't this work:

A byte is 8 bit, and a char 16 (and unsigned). So why doesn't this work?
12 years ago

Another question from the K&B bonus master exam from the attached CD. A question was asked about many multi-dimensional arrays. Say you have the followig array declared:

And now we are going to store a new 2 dimensional array into that array:

I didn't expect this to work (maybe at compile time, but certainly not at runtime). What happens in memory?
Still unclear to me. Say I have the following code:

As far as I know I can still pass a list with any generic type. Where is the restriction? What invocation will fail in this case?

I've encountered the following code in the OCJP mock test from the K&B study guide book attached CD, and I think this is not covered in the Study Guide:

I'm really not getting why you should write ? extends T or ? super T. What are the implications? T is defined nowhere?

? super Cat makes sense to me. This implies that you can add Cats to the list passed in.
? extends Animal also makes sense. This implies you can iterate any incoming list using the Animal object type.