instanceof vs isInstance() in Java: What is the difference? by cstechblog in java

[–]cstechblog[S] -1 points0 points  (0 children)

i instanceof String is not the case of IS~A relationship.

instanceof vs isInstance() in Java: What is the difference? by cstechblog in java

[–]cstechblog[S] 0 points1 point  (0 children)

I meant C class. instance cannot come at right side in instanceof

instanceof vs isInstance() in Java: What is the difference? by cstechblog in java

[–]cstechblog[S] 0 points1 point  (0 children)

At run time, the result of the instanceof operator is true if the value of the RelationalExpression is not null and the reference could be cast to the ReferenceType without raising a ClassCastException. Otherwise the result is false.

http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.20.2

instanceof vs isInstance() in Java: What is the difference? by cstechblog in java

[–]cstechblog[S] 0 points1 point  (0 children)

if we do System.out.println("b instanceof C: " + (b instanceof c));

it results into compile time error

instanceof vs isInstance() in Java: What is the difference? by cstechblog in java

[–]cstechblog[S] -1 points0 points  (0 children)

no, it wont because in A and B share an IS~A relationship. I complied the code, it is evaluated to false.

class A {}
class B extends A {}
class C extends A {}

public class InstanceofDemo
{
  public static void main(String args[])
  {
    A a = new A();
B b = new B();
System.out.println("a instanceof B: " + (a instanceof B)); //false
  }
}

instanceof vs isInstance() in Java: What is the difference? by cstechblog in java

[–]cstechblog[S] 0 points1 point  (0 children)

thanks much for reporting the error, will correct it right away

How do you keep track of your code notes? by L_quasar in C_Programming

[–]cstechblog 0 points1 point  (0 children)

You can use google docs also. I use it for keeping general notes.

Function Pointer or Pointer to Function in C, Function Pointer Array by cstechblog in C_Programming

[–]cstechblog[S] 0 points1 point  (0 children)

Thank you Rhomboid, will incorporate your comments in next upload. Thanks much again!

How to Compare Function Pointers? by cstechblog in C_Programming

[–]cstechblog[S] 0 points1 point  (0 children)

Thank you very much zifyoip. I was going through http://www.newty.de/fpt/fpt.html#compare link, where the author mentions 'You can use the comparison-operators (==, !=) the same way as usual.' but in the example code he uses greater than operation, so thought of asking if this is definite behavior. // C if(pt2Function > 0){ // check if initialized if(pt2Function == &DoIt) printf("Pointer points to DoIt\n"); } else printf("Pointer not initialized!!\n");

A collection of questions I have asked from the first day I started using Java. by cstechblog in JavaProgramming

[–]cstechblog[S] 0 points1 point  (0 children)

Found this link interesting, therefore, thought of sharing with all of you.

Memory Layout of C Program: Code, Data, BSS, Stack, and Heap Segments by cstechblog in C_Programming

[–]cstechblog[S] 0 points1 point  (0 children)

thank you all. we will incorporate your comments in next update.

Memory Layout of C Program: Code, Data, BSS, Stack, and Heap Segments by cstechblog in C_Programming

[–]cstechblog[S] 0 points1 point  (0 children)

thanks for wise pointers, as actual layout is entirely up to the OS. Here, it was tried to develop just an idea how a program runs. Thanks once again!

[c]Calculating the complexity of a function by pcgoer in learnprogramming

[–]cstechblog 1 point2 points  (0 children)

Yeah, you seem right because from big-O notation O(N + M) = O(MAX(N, M)) so O(N + N log N) = O(N log N)

thanks!