Is java Class Thread safe ???? How to make java Class Thread
safe ??
Answer / avinash pandey
NO Java class is not Thread Safe , for making thread safe to
Java class we have to use either Synchronized method or
Synchronized block...
Is This Answer Correct ? | 28 Yes | 1 No |
Which is faster c++ or java?
What is a bean class?
What are struts java?
What is the use of servlet in java?
Do I need both jdk and jre?
What is Serialization?
What is setstring method in java?
public class Dog { private int weight; public int getweight(){ return weight; } public void SetWeight(int newWeight){ if (newWeight > 0){ weight = newWeight; } } } public class TestDog { public static void main(String[] args) { Dog d = new Dog(); System.out.println("Dog d's weight is " + d.getWeight()); d.setWeight(42); System.out.println("Dog d's weight is " + d.getWeight()); d.setweight(-42); System.out.println("Dog d's weight is " + d.getWeight()); } } class dog is compiled but there is an error in class TestDog when compiled and the error is with dot notations. I want to kmow why there is error in testdog class when compiled.
What is dependency injection in java?
What is lambda used for?
What is the java api?
What is meant by swing in java?