I am working on a project for my Data Structures class that asks me to write a class to implement a linked list of ints. Use an inner class for the Node. Include the methods below. Write a tester to enable you to test all of the methods with whatever data you want in any order. I have to create
Tag: methods
Java, my own copy() method would not work
I am learning java and came upon a small problem, my copy() method will not work. I work based on a UML diagram and I am pretty sure that I’m doing everything correctly. Here is the code: Constructor: copy() method: The error flashes at the parantheses FileName() it says: ‘FileName(java.lang.String, java.lang.String)’ in ‘Exam_Practice_4.FileName’ cannot be applied to ‘()’ Here is
Need help understanding basic recursion problem
I have just started practicing with recursion I have this very simple practice program problem. There are bunnies standing in a line, numbered 1,2,3… The odd bunnies (1,2,3..) have normal 2 ears. The even bunnies (2,4,6…) have 3 ears, because they each have a raised foot. Recursively return the number of ears in the bunny line. I have the solution.
How to call a method twice in a row?
I have a code where in my class I would like to be able to call the method answer twice like qns.answer(5).answer(7). But right now when I call the method answer as below, I get the error cannot find symbol. For example: Would appreciate if you could kindly give some pointers on how to get around this. Answer Question can
How can I prevent an overwrite and add to exisiting array (Java)
My project mostly works as intended, save for the fact that my methods will overwrite the initial entry and not add the new entry to the array. For instance if I input 2 entries via option 1, and then attempt to add another (single) entry via option 2, index 0 is overwritten by the new entry. I’ve tried making the
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. And I have a second class Professor, that has first name, last name, and university. And I have a method to print the info about the professor. And in the main class I create two
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. My current way of doing this is grabbing the command they executed, then just using and if else if statement which looks something
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 class implements (including the methods implemented by super-classes). A specific method is simply represented by an index into that table. The JVM looks up 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 …