primitive Questions
1
Solved
Looking at both the docs and the code, it appears that str is a primitive type, while String is a struct { Vec<u8> }. Now as str is to a [u8] what String is to a Vec<u8>, couldn't str h...
5
Solved
I have a Java class of the following form:
class Example {
private byte[][] data;
public Example(int s) { data = new byte[s][s]; }
public byte getter(int x, int y) { return byte[x][y]; }
pu...
Coley asked 3/4, 2013 at 15:11
2
Solved
Why when I use this code,
int[] array = new int[3];
array[0] = 0;
array[1] = 1;
array[2] = 2;
System.out.println(Arrays.asList(array).contains(1));
it outputs false. But when I use this code,
I...
Counterblast asked 22/5, 2015 at 14:21
5
public class Primitive {
public static void main(String []args) {
byte x=5;
Double y=(Double)x; //Error : Cannot cast from byte to Double.
Byte n=7;
Double m=(Double)n; //Error : cannot cas...
15
Solved
I have been programming in Java since 2004, mostly enterprise and web applications. But I have never used short or byte, other than a toy program just to know how these types work. Even in a for lo...
2
Solved
Is there a package that defines the size of Java primitives that I can import in my project? I'm doing some manual bit setting and I keep a byte index. I don't want to do currentByte += 4 when I se...
Ehlke asked 2/4, 2015 at 15:35
5
Solved
If you use BigInteger (or BigDecimal) and want to perform arithmetic on them, you have to use the methods add or subtract, for example. This may sound fine until you realize that this
i += ...
Passive asked 26/2, 2015 at 15:19
5
Solved
public class Foo {
public static void main(String[] args) {
float f;
System.out.println(f);
}
}
The print statement causes the following compile-time error,
The local variable f may not ha...
1
Solved
I have been studying Decorator pattern and developed simple class ToUpperCaseInputStream. I overrode read() method so it could convert all chars from InputStream to uppercase. Code of the method is...
Baxley asked 17/1, 2015 at 19:6
7
Solved
Unlike Java or C#, primitive data types in C++ can vary in size depending on the platform. For example, int is not guaranteed to be a 32-bit integer.
Various compiler environments define data types...
Memorandum asked 6/9, 2009 at 13:41
3
Solved
It's been rehashed over and over that primitive types don't have constructors. For example this _bar is not initialized to 0 when I call Foo():
class Foo{
int _bar;
};
So obviously int() is not...
Wheaten asked 12/12, 2014 at 12:19
10
Solved
In C++, I enjoyed having access to a 64 bit unsigned integer, via unsigned long long int, or via uint64_t. Now, in Java longs are 64 bits, I know. However, they are signed.
Is there an unsigned lo...
Courtesan asked 3/2, 2009 at 19:50
3
Solved
Please take a look at below example i cant understand the relation between char and byte
byte b = 1;
char c = 2;
c = b; // line 1
Give me compilation Error because c is type of char and b is ty...
4
Solved
I have two Arrays of unknown type...is there a way to check the elements are the same:
public static boolean equals(Object a , Object b) {
if (a instanceof int[])
return Arrays.equals((int[]) a,...
6
Solved
In Java, does it cost memory to declare a class level instance variable without initializing it?
For example: Does int i; use any memory if I don't initialize it with i = 5;?
Details:
I have a hu...
Aparri asked 27/10, 2014 at 10:13
6
I want to write a function or a directive like NSLog() that takes any kind of variable, primitives and objects. In that function I want to distinguish those.
I know how it works for objects:
- (...
Jumpy asked 6/4, 2012 at 15:23
7
Solved
I'm writing an application that uses Dijkstra algorithm to find minimal paths in the graph. The weights of the nodes and edges in the graph are float numbers, so the algorithm doing many arithmetic...
Mccowyn asked 28/7, 2010 at 7:39
1
Solved
I'm using a third party C++ API for my project and it has functions with return values with types std::vector<int>, std::vector<bool>, std::vector<double>. I need to pass variable...
Vitta asked 5/6, 2014 at 8:1
8
Solved
A discussion earlier today led me to question whether or not my understanding of primtives and literals is correct.
My understanding is that a literal type is specifically a type which can have ...
Candidate asked 14/1, 2010 at 17:15
3
Solved
I have a situation where I have to change java constant.
I have below code working
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
public class Main {
public static final In...
Zosema asked 24/4, 2014 at 15:56
4
Solved
I know that, in C++, when you write
int i;
you can not make any assumptions about the value that the variable will hold until you effectively assign it a value. However, if you write
int i = in...
Patent asked 24/4, 2014 at 8:33
1
Solved
public class Primitive {
void m(Number b, Number ... a) {} // widening, autoboxing->widening->varargs
void m(byte b, Number ... a) {} // unboxing, autoboxing->widening->varargs
pub...
Downtime asked 11/4, 2014 at 18:53
2
Solved
I just came off an interview where I needed to use this value for the algorithm I came up with. After the interview I was curious if there was actually a way to get the max Int value.
I am aware o...
5
Solved
How do you declare, set properties, synthesize, and implement an int array of size 5 in Objective C? I'm writing this code for an iphone app. Thanks.
Libb asked 26/5, 2009 at 18:23
2
Solved
1) Why is the following assignment not allowed:
byte b = 0b11111111; // 8 bits or 1 byte
but this assignment is allowed:
int i = 0b11111111111111111111111111111111; //32 bits or 4 bytes
Both ...
© 2022 - 2024 — McMap. All rights reserved.