All Questions
2,113
questions
-2
votes
0
answers
38
views
Returning an array of raw type but instead of an array of parameterized type specified at the header
protected Collection<Node> createBucket() {
return new LinkedList<>();
}
/**
* Returns a table to back our hash table. As per the comment
* above, this table can be an array of ...
1
vote
0
answers
77
views
Why does type inference fail in this Java program?
Let's consider the following Java program:
import java.util.*;
import java.util.stream.Collectors;
public class Main {
record Foo(String id, List<Bar> bars) {}
record Bar(String id) {}...
0
votes
1
answer
71
views
How to get unknown nullability function return type in Kotlin?
What I want to achieve is to get Any! return type from function, so I can determine myself whether to handle nullability or not. The only way to get this type I found is to call a Java function.
For ...
0
votes
0
answers
30
views
GetFloat returns different value for number more than 7 decimal digits [duplicate]
We are using getfloat() to fetch the record. But when we saved the data in the table value stored was different from the original value.
Float givenFloat = new Float(16797533);
String result = String....
0
votes
1
answer
88
views
Cast a dart int as long(Java)
In my flutter/dart app i am using channel.invokeMethod() to run code on the Android side. When i pass a dart int via this method i get a Java Int or Long, depending on the value that i sent.
Eg.:
if ...
-2
votes
2
answers
50
views
difference between .equals() and == [duplicate]
I don't know why after using .toString() and having our new String, we need only to use .equals instead of == when we want to compare. But other strings can be compared with ==. Why is that and what ...
0
votes
1
answer
32
views
Type incoherence when compiling Java code through GWT
I am building a web project using the GWT library. For some reason when compiling through GWT pieces of code similar to this
double a = 0, b = 0;
long c = Double.doubleToLongBits(Double.sum(a, b));
...
1
vote
2
answers
101
views
Boolean.FALSE: When should it be used?
I have been reading the book Crafting Interpreters by Robert Nystrom and came across the following code:
if (!scopes.isEmpty() && scopes.peek().get(expr.name.lexeme) == Boolean.FALSE) { // <...
-2
votes
1
answer
58
views
Is there a way to create methods within a method? Like coding to create code, but within the same code?
Okay, so this is a bit complicated and I don't know that it will work but here is what I'm trying to see if is possible:
If I create a method in java, or write java code, can that method or code edit ...
0
votes
3
answers
115
views
Primitive Integert Datatype Limits in Java
I have a Java programt o display the limits of primitive integer datatypes which is as follows:
import static java.lang.Math.*;
class HelloWorld {
public static void main(String[] args) {
...
0
votes
0
answers
24
views
Java compiler API convert TypeMirror to Type
I hardly ever used the Java compiler API before, so I have very little experience with it. I want to get the type of the class my MethodTree is in as a Type. This is what ChatGPT gave me, but it ...
1
vote
5
answers
919
views
How to Change the Type of a Variable in Java?
I am working on a Java project and have encountered a situation where I need to change the type of a variable during runtime. Is there a way to do this in Java?
void doSmth(){
String var = &...
2
votes
1
answer
60
views
Java type which accepts a class AND its interfaces (contravariance)
I have a class and an interface like this:
interface Employee {...}
class Developer implements Employee {...}
Then I have classes which implement steps in the onboarding process:
interface ...
0
votes
0
answers
38
views
Type Inference specificity does not make sense (How it determines most specific type)
Hi from the following tutorial: https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html.
It says type inference algorithm "tries to find the most specific type that works with ...
1
vote
1
answer
145
views
Java Spring Reactive return error message to user OR json of some Object
My first question, so please be understanding if I miss something.
So I need to do something similar to this image (but working):
@GetMapping("/search")
public Mono<ResponseEntity&...