Skip to content
Advertisement

Tag: class

Javac Not found after setting the path

I was messing around with writing Java code without an ide, and compiling/running with command prompt. When I try to create the .class, I get an error saying that Javac is not recognized. I was looking for answers when I found this thread https://stackoverflow.com/questions/1299750/javac-not-recognized But nothing was working. I have done the following Set C:Program FilesJavajre1.8.0_51bin as a path Set

Print user inputs from 2D array using another class in Java?

I am trying to print user inputs in another class in Java. I have made a chessboard which asks the user to input strings on the board, and then, when these strings are printed on screen, I would like the output to be “You have placed piece [name] at coordinate [coordinate]”. I am trying to do this in another class

Casting an Object into a Class of type T

Let’s say I have an empty class called ClsA(), and a subclass of it called ClsB() like so: Supposing that we now have an ArrayList of ClsA type objects, I want to be able to count how many elements in the ArrayList are actually of type ClsA or ClsB. Based on some searching, I found out that the following function

How to search in arrayList then change?

So i’m making a supermarket program that allows to add products and sell them, so far i have this: I´d like to know how to search in Product list by name and then change the stock(subtract-n) to sell n of that product. Answer You can use Stream API to find out the product by name. Filter the list by checking

Object array with variable from another class

Worksheet Question: The question said to declare an array of 5 objects of the class Node in the main Class – I managed to this as shown below But then the question continues populate the array by objects with seqNo values assigned to 1,2,3,4,5 respectively. Then traverse the array and print the list of its object using method show() I

Variable value not being passed into another class

I’m trying to let the user to choose which option is in their menu, and setting the variables based on the option that the customer choose, but when I go to another class and retrieve it, there is no value being passed. Here is my alacarte class Here is my checkout class Here is my output Answer You have all

Java Exercise: I’m not sure what I’m doing wrong and all help is appreciated

I am working with the following pieces of code and I keep getting this error message: Error: Main method not found in class Team, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application. All suggestions, opinions, and changes are welcome as I am completely lost on why this isn’t working.

Advertisement