When SwingWorker is used to report task progress, it should be noted that the propertyChangeEvent won't be invoked if the oldValue is the same as the oldValue. To solve this problem, it is better to reset your progress status to zero or random number before the SwingWorker starts. The setting will force the propertyChangeEvent to be invoked. So your progress status will be updated.
In java, we have two operations (" == " and " equals() ") to check the equivalence of String s. It is important to understand that the difference between them. == The == operator compares the two objects and checks to see if two objects are exactly the same object (refer to the same instance). .equals() The equals() method compares the characters in the two different objects. Two strings may be different objects , but can contains the same values (exactly the same characters). public class Main { public static void main(String[] args) { String s1 = "Shangshu"; String s2 = new String(s1); System.out.println(s1 + " == " + s2 + " is " + (s1 == s2)); System.out.println(s1 + ".equals(" + s2 + ") is " + (s1.equals(s2))); } } The output of the above code is:...
Comments