public class testtype
{
private int a;
private double b;
testtype(int a,double b)
{
this.a=a;
...
|
I have a long piece of code that calculates two values (doubles) for me, I use this piece of code in a few places - to stick with DRY principles I ... |
To get a newString value of "99 bottles":
int x = 99;
String fruit = " bottles";
To form a new String I do this:
String newString = "" + x + fruit;
since this is ... |
Good Afternoon
I have java primitive int and its wrapper Integer ,do it mean that the int has the same Maximum value as Integer's maximum value ?
thanks
|
Another Newbie one: Class Pi { double value = 3.14 public string toString() { Double d = new Double(value); return d.toString(); } } public class D { public static void main(String[] args) { Pi pi = new Pi(); System.out.println("before:" + pi); zero(pi); System.out.println("after:" + pi); } static void zero(Pi arg) { System.out.println("top:" + arg) arg.value = 0.0; System.out.println("middle:" + arg) arg ... |
|
Hi, Thanks for the reply.I was working on the above problem.When i do binary to decimal conversion of 16 bit of short 1011 1011 1111 1010-it gave the answer -48122 instead of giving the answer -17414.My answer is -48122 is not correct.-17414 is the correct answer.but i couldnit still figure out how to get the result.Please share your knowledge. |
|
Hi All, I have a small doubt on the max value that a short(data type) variable can take. Short can accomodate 16 bits, of which the left most bit is a sign bit and the remaining 15 bits represent value. So the max value that can be accomodated by the short variable is (2^15-1). (^ represents the power symbol). Does Java ... |
hi what are the range of values that can be stored in primitives like int,char,byte,short,long,float,double. please specify the range in exact numbers. like i guess that a byte should be able to store 255 to the maximum because it has 8 bits. but the k&b book has a saying that 128 is quite big for a byte?? is it due to ... |
Ya i agree with you but taking as Object as a parameter will convert primitive to object . i want exactly like this in primitive Nope. Won't work. There is no option to have a single method take multiple primative types -- as primatives. If you want to provide this option to your callers, you have to do some work -- ... |
|
When I pass an integer from my main method to another method, it passes by value and the original variable is left unchanged. My question is: How do you change the value of the original variable, and not just the 'copy' of that variable in my other method? I would also appreciate it if you could explain this in 'dumbed down' ... |
I am trying to determine if java primateives (like an int) have default values. On sun's web page I read this: "It's not always necessary to assign a value when a field is declared. Fields that are declared but not initialized will be set to a reasonable default by the compiler. Generally speaking, this default will be zero or null, depending ... |
I have a variable of type long. This variable is accessible by more than one thread. I have threads that only read the value of that variable, and I have threads that read and also write the value. Suppose the value of the variable is being changed by a thread. This thread is changing the value from 1051 to 1055, in ... |
I tried to calculate 2^62 iteratively, but at the end I get a negative value. You must have done something wrong but fixed the error because your current code gives 2^62 = 4611686018427387904, which is correct. To elaborate the above post, literal integer constants are, for some strange reason, implicitely of int type, and values outside of the int range are ... |