Slight improvements of your current code
- Get rid of the comments and read three lines below which symbol you are currently declaring the conditions for. Your code is very self-documenting, no need to add comments.
You should know that there is a more than or equal to operator, which can be used to make your code a lot more readable (here I have also removed the braces since your statement is only one line)
if (id >= 1 && id <= 13) this.symbol = Card.HEARTS; else if (id >= 14 && id <= 28) this.symbol = Card.KARO; else if (id >= 28 && id <= 41) this.symbol = Card.CLUBS; else if (id >= 42 && id <= 52) this.symbol = Card.SPADES;
This can in turn also be simplified to:
if (id <= 0) { /* mega-super-error-should-probably-not-happen-and-if-it-does-then-it's-no-symbol */ } else if (id <= 13) this.symbol = Card.HEARTS; else if (id <= 28) this.symbol = Card.KARO; else if (id <= 41) this.symbol = Card.CLUBS; else if (id <= 52) this.symbol = Card.SPADES;
Weird King
Are you aware that in your current code, you will have the values 1 2 3 4 5 6 7 8 9 10 11 12 0? This feels weird. If Ace is 1 then 0 is king I assume? But using 0 as king does not make sense.
Adding a parameter to the function
Even though @rolfl provides a short way to do this, I just want to object to one thing: The use of the id parameter.
It seems like you are creating a card from an ID. Now what if you some day totally forget about how to calculate these IDs from a specified suite and rank? (or vice versa). I would instead use a function with two parameters: Suite and rank. I'm not sure how you are calling this method today, but to me it feels cleaner to create cards by using a nested for-loop to loop first over suite and then over rank, rather than looping from 1 to 52.
Also, I wouldn't use an uppercase property VALUE when the others, symbol and card is lowercase. It's better to use lowercase value also. Or, you could call it rank instead. And you might want to rename the card property to picture.
As for how to do it in Java, I would say that you should try to make it the same in both Java and JavaScript. Tidy up the JavaScript and then make it the same in Java.