Linked Questions
20 questions linked to/from Does Java casting introduce overhead? Why?
2 votes
1 answer
947 views
Java: Does primitive type casts performance impact? [duplicate]
Is it faster to assign a long value to an int variable using a cast or is using a long variable faster? Or it is a choice, between consuming more memory and processing more? Here is an example test: ...
57 votes
4 answers
81k views
What is the benefit of ViewHolder pattern in android?
When you are developing an Android program; and you want to have a ArrayAdapter you can Simply have a Class (most of times with ViewHolder suffix) or directly inflate your convertView and find your ...
18 votes
5 answers
26k views
What is the cost of casting in Java? Is it a good idea to avoid it? [duplicate]
I know there are two types of casting that are implicit and explicit castings. I read different questions on the StackOverflow such as this, this and this but I am still wondering what is the cost of ...
18 votes
6 answers
48k views
Hibernate 5.2 version -> A lot of Query methods deprecate?
I'm new to Hibernate. I'm trying to get a list of first name and last name of all administrators. There are two warnings in my following code. I already tried to search a lot online. 1) Query is a ...
14 votes
10 answers
16k views
"Double casting"
I'm currently tutoring a high school student in AP Java and she asked me a question about "double casting". I did not ever hear of this term before, but apparently her teacher expects her to know it ...
8 votes
6 answers
4k views
How much processing and memory use does casting take in Java?
I am considering whether it is better to have two pointers, one for each object sub class and super, or whether I should just use casting. How much system resources does this use: objectName....
4 votes
3 answers
3k views
Casting performance in Java
I've a Servlet filter which performs the following type cast: HttpServletRequest httpRequest = (HttpServletRequest) req; At present my filter is responsible for two tasks that would be better ...
6 votes
5 answers
957 views
Is the performance/memory benefit of short nullified by downcasting?
I'm writing a large scale application where I'm trying to conserve as much memory as possible as well as boost performance. As such, when I have a field that I know is only going to have values from ...
2 votes
4 answers
2k views
Is using a generic FindViewById a bad practice?
Situation I have a BaseActivity from which I extend other activities. In the BaseActivity I have a findCastedViewById which basicaly casts the view and then returns it. I do this because I, ...
0 votes
5 answers
747 views
java Type safety:not parameterized generic type effect on performance
i want to know if there is only safety risk or there are also other benefits i get when parameterizing the list. i get this warning List is a raw type References to generic type List should be ...
1 vote
4 answers
899 views
Java beginner: does casting result in lower performance by any mean?
when I create Animal x=new Dog(); and I want to use Dog functions, I would have to cast right ? ((Dog)x).bark(); so let's say I would use this many times in for loops does that result in lower ...
5 votes
2 answers
278 views
Why does a String-casting loop seem to have a static overhead?
Background I've been running a code (posted at the bottom) to measure performance of explicit Java downcasting, and I've run into what I feel like is a bit of an anomaly... or perhaps two anomalies. ...
1 vote
1 answer
1k views
Casting Interface to Class in Java
In Java there is a method that has a parameter, and this parameter is an Interface. Using such method can I do a cast to a concrete class? How can I calculate the cost of this cast performance-wise? ...
0 votes
4 answers
959 views
How java casting work, is it change the state of Object or create new Object?
I have a method dummy with A as class parameter, but i need to pass instance of subclasses B to that method. I know from: Does Java casting introduce overhead? Why? that downcasting in java have ...
-3 votes
6 answers
406 views
Compere if statement short form
ı want to use short form for if statement. How can ı write if statement at one line? and how can ı compare them ı know there is same question at here. but my statement do not have else so ı could not ...