Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
-
is possible to define abstract static method? i.e., the method doesn't depend on any instance variables but subclasses have different implementations
-
for a void method, we can also make it return values. Sometimes it can be more convenient to have it return value. Generally speaking what's the advantage of void methods? faster?
-
how can I make a copy of the subclass which implements an abstract class?
-
if a getter method doesn't return a deep copy of an object, then there's no advantage over making it protected, right?
-
if a class don't have any instant variables, what's the advantage of making it a static class?Create a new object is expensive? But how expensive it is for simple classes that only have static members? I guess for classes that have both static and non-static method, reference by class name is preferred. But ...
-
if a instance variable (need not to be initialized manually) is affected by multiple instance varibles, what the best way to update them? I currently use a single method to update them all to avoid possible issues, but it's less convenient, and confusing.
-
if you write a generic class, for example MyClass
, how do you make a defensive copy in the constructor? -
java ArrayList
>, if i remove an elment of the list, but the element of the elment (also a list) is still in use, will there be memory leak?
input and output
-
good way for random access file?
-
concurrency
-
johnson told me that we have to protect shared data even if we sum a bunch of values together, because of thread local cache, if this is the case, how can we avoid using lock? there are some algorithms that are thread safe without lock ...
-
atomic seems to be more tight than volatie. I think atomic can replace volatile if you do not consider performace, while volatitle can not replace atomic. Atomic is for interaction between threads ...
-
about mutex, if an object has two fields that are shared, thought they are independent, still only once thread can access the object no matter which filed it access ... This is not true, you can use multiple mutex, so that these two fields can be access by different threads if that's safe.
-
difference between lock and readwirtelock, the former allows only thread to access the shared resource while the latter allows multiple to read or exclusive to write.
other
-
the working directory of java class seems to be the directory where you run the command.
-
how to get the directory where the java application is? there seems to be some solution online
-
how to patch files into jars so that they can always be found and used in java program?
exception
- when to handle exception is a big problem ...
lambda
- lambda function in java? currently we cannot pass method as argument to another method. Interface for comparing is OK but not flexible, if generics functions e.g., sort take lambda function, then it's more comveneint.
exception
- when to handle exception is a big problem ...
class and object
-
is possible to define abstract static method? i.e., the method doesn't depend on any instance variables but subclasses have different implementations
-
for a void method, we can also make it return values. Sometimes it can be more convenient to have it return value. Generally speaking what's the advantage of void methods? faster?
-
how can I make a copy of the subclass which implements an abstract class?
-
if a getter method doesn't return a deep copy of an object, then there's no advantage over making it protected, right?
-
if a class don't have any instant variables, what's the advantage of making it a static class?Create a new object is expensive? But how expensive it is for simple classes that only have static members? I guess for classes that have both static and non-static method, reference by class name is preferred. But ...
-
if a instance variable (need not to be initialized manually) is affected by multiple instance varibles, what the best way to update them? I currently use a single method to update them all to avoid possible issues, but it's less convenient, and confusing.
-
if you write a generic class, for example MyClass
, how do you make a defensive copy in the constructor? -
java ArrayList
>, if i remove an elment of the list, but the element of the elment (also a list) is still in use, will there be memory leak? -
Java container resize, how to make sure the length of array won't overflow?