Skip to content
Advertisement

Tag: methods

Calling methods and how to use them

The task I am trying to do is to utilise the given classes and methods are to take the money from the richest account and give it to the poorest so they have the same balance and to print “(name) has $(amount).” I am clueless on which method to use and anything I try gives an error or and incorrect

Two java files. Getting IllegalAccessError when running class with main method trying to access a method from the other file

Learning Java. I have two files, each containing one java class. When I run the file with the main method, I get the following error: Exception in thread “main” java.lang.IllegalAccessError: failed to access class TapeDeck from class TapeDeckTestDrive (TapeDeck is in unnamed module of loader ‘app’; TapeDeckTestDrive is in unnamed module of loader com.sun.tools.javac.launcher.Main$MemoryClassLoader @18bf3d14) at TapeDeckTestDrive.main(TapeDeckTestDrive.java:3) Any help please?

Are values returned by static method are static?

Please consider this code Will this static method return a new instance of MyClass every time it is called? or it is going to return a reference to the same instance over and over? Answer Lol lol lol Declaring a method static means it is a class method and can be called on the class without an instance (and can’t

ATM Machine in Java

I have been trying to figure out what is going wrong with this program I’m writing. Heres the full description of what I’m trying to do: Use the Account class created in Programming Exer- cise 9.7 to simulate an ATM machine. Create ten accounts in an array with id 0, 1, . . . , 9, and initial balance $100.

null pointer exception error calling method

I get this null pointer exception error if i call a method. if (farm1.cropStat(row, col) ) here’s the method here’s the initialization pls help 🙁 Answer Whenever you see a pattern that looks like this replace it with the equivalent It is the same thing. As far as the error goes, you need to reverse the order of your checks

Advertisement