When is the finalize() method called in Java?

In general it’s best not to rely on finalize() to do any cleaning up etc. According to the Javadoc (which it would be worth reading), it is: Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. As Joachim pointed out, this may never happen in the life … Read more

What does ‘public static void’ mean in Java?

It’s three completely different things: public means that the method is visible and can be called from other objects of other types. Other alternatives are private, protected, package and package-private. See here for more details. static means that the method is associated with the class, not a specific instance (object) of that class. This means that you can call a static method without creating … Read more

Pass Method as Parameter using C#

You can use the Func delegate in .net 3.5 as the parameter in your RunTheMethod method. The Func delegate allows you to specify a method that takes a number of parameters of a specific type and returns a single argument of a specific type. Here is an example that should work:

Passing just a type as a parameter in C#

There are two common approaches. First, you can pass System.Type This would be called like: int val = (int)GetColumnValue(columnName, typeof(int)); The other option would be to use generics: This has the advantage of avoiding the boxing and providing some type safety, and would be called like: int val = GetColumnValue<int>(columnName);

Why nextLine() and not nextString() ?

Consider this: nextLine return everything until next endline (\n) in form of String. Would you not think that you will retrieve everything if it was called nextString? In that case you would be posting question “why nextString() stops at endline” tl;dr it’s because it searches for endline (\n) upd: on documenatation it refers to it … Read more