Java: How to access methods from another class

You need to somehow give class Alpha a reference to cBeta. There are three ways of doing this. 1) Give Alphas a Beta in the constructor. In class Alpha write: and call cAlpha = new Alpha(cBeta) from main() 2) give Alphas a mutator that gives them a beta. In class Alpha write: and call cAlpha … Read more

Java GUI: about getContentPane( ) method and content

Every JPanel is a container, so either add it to a panel then add it to the container or directly use add(component) or use the getContentPane().add method. Both add the component to the container in Java 7 (I don’t know if version 6 has a problem with this or not).

Can’t install JDK 9 because “Another Java installation is in progress”

On Windows, Java prevents starting the Installer twice by creating (two) lock files. If those files exist, Java Installer show the Message: “Another Java installation is in progress (…)”. If Java Installer crashes, or Windows crashes during Java Installation, the installer cannot delete the lock files when finalizing. Solution: Deleting the lock files, unlocks the … Read more

How to use Comparator in Java to sort

There are a couple of awkward things with your example class: it’s called People while it has a price and info (more something for objects, not people); when naming a class as a plural of something, it suggests it is an abstraction of more than one thing. Anyway, here’s a demo of how to use a Comparator<T>: EDIT And an … Read more

How to solve error lossy convertion from int to char?

You can have an overflow when doing mathematic opetations between integers and chars, this can affect the expected result since that value is going to be assigned to a char… here you have but you should cast to char like:

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)