Skip to content
Advertisement

Tag: methods

How can I implement interface correctly?

I am doing homework of making a simple calculator using java and interface in java. but the class that implements java gives error saying here is the code Answer There are a couple of issues here. First, since BasicCalculator is a public class, it needs to be defined in its own file named BasicCalculator.java. Second, the method names in BasicCalculator

Java – generate and rotate matrix

recently I’m trying to learn Java a bit and currently, I’m working on a simple program that should generate a matrix and then rotate it. I’m stuck at the first part. What exactly is the problem? The logic of my code seems to be fine, but anyway program is returning not what I would expect. The code: Output: Please, enter

Having issues calling a decorator method (Java)

Working on a group project that is essentially a text-based Pokemon rip-off. My classmates and I were given a UML to work from so I can’t accept any solutions that would add methods or change their parameters. But essentially the issue we’re running into is this: There is a singleton PokemonGenerator class, that has a method generateRandomPokemon(int level) that picks

Call method in Fragment from some class

I’ve been working on Android App in AndroidStudio. Application has Fragment, let’s call it MainFragment, and seperate Java Class file, let’s call it SQLiteControler.class The problem is when i try to call method from Fragment in SQLiteController im getting null object reference as error Here is some minified code: MainFragment SQLiteController Note: This is minified code I have tried, a

Issue with addressing variables from different method

I am just learning to code in Java and ran into a problem. The task description was following: “The class SalaryCountingWithMethods below asks for three floating point numbers (work hours, salary per hour and tax percent) and then counts the salary before and after taxes as well as the tax part of the salary based on the information given to

Advertisement