How to create objects for parameterized constructors in Java, when we have two classes with the same attributes?

I have class Student, that has first name, last name and age, and a method to print the name and the age of the student. public class Student { private String firstName; private String …

Representation of an array as a polynomial

What this method should do is take an array of doubles and convert them into a polynomial, for example, if the array is given was [2.0, 3.0, -2.0] the method’s output would be 2.0x^2 + 3.0x^1 – 2.0. …

Is there a better way than a bunch of if statements to call my methods?

I am currently writing a plugin for SpigotMC/Minecraft. It is written in Java. In my code, found on my Github I am attempting to call a different method depending on what the input of the player was. …

Implementation of invokevirtual in JVM

I had expected that the Java Virtual Machine would use a simple lookup table for normal method invocations: The object contains a pointer to a lookup table with the addresses for all methods that the …

Acces an ArrayList on a different method (same class)

im trying to acces the ArrayList “Lista” (with the modifications it had in the “Guardar” method) in the “verJugadores” method, is this possible? When I print the …

How do i pass variables into methods – java [closed]

I need to use a variable from one method in another. Here is the code: public static void secondMain() { BufferedReader reader; var lines = new ArrayList(); var …

Trying to understanding Exit, Loop, Method and If and Else [JAVA]

Hello guys I need help with my code. I am trying to understand how to use the method, loop,if-else statement, and exit code. So I’m writing a simple calculation base on the user choice but right now I …

Java class and methods returning wrong value

I am writing code in java to simulate entering a circus at a very low level code wise. It is just a couple of classes under a main class, Customer. My code is just the main class and its methods, then …

Storing methods identifiably in Java

I’m trying to come up with a solution to a problem where I want to store method references in some way so that I can invoke them when needed and remove them when I don’t need them on my list of …

Java Evaluating RPN using Shunting Yard Algorithm

I have the shunting yard algorithm that I found online: import java.util.HashMap; import java.util.Map; import java.util.Stack; public class ShuntingYardAlgorithm { private enum Operator { ADD(…