Posts

Oracle Date How to Add Day , Hour, Minute, Second to a Date Value:-

1)Oracle add Days 2)Oracle add Hour 3)Oracle add Minute 4)Oracle add second -- # Add a day select  to_char(sysdate,'dd-mm-yyyy hh24:mi:ss') "Todays-date" , to_char(sysdate  +1 ,'dd-mm-yyyy hh24:mi:ss') One_day  from dual ; Todays-date         ONE_DAY ------------------- ------------------- 05-01-2012 12:55:52 06-01-2012 12:55:52 -- # Add an hour select  to_char(sysdate,'dd-mm-yyyy hh24:mi:ss')  "Todays-date" , to_char(sysdate  +1/24 ,'dd-mm-yyyy hh24:mi:ss') One_hour from dual ; Todays-date         ONE_HOUR ------------------- ------------------- 05-01-2012 12:56:06 05-01-2012 13:56:06 -- # Add an Minute select  to_char(sysdate,'dd-mm-yyyy hh24:mi:ss') "Todays-date" , to_char(sysdate  +1/(24*60) ,'dd-mm-yyyy hh24:mi:ss') One_minute from dual ; Todays-date         ONE_MINUTE ------------------- ------------------- 05-01-2012 12:...

String literal pool & Creating the String object Using new()

What is String literal pool? How to create a String There are two ways to create a String object in Java: Using the  new  operator. For example,  String str = new String("Hello"); . Using a  string literal  or  constant expression) . For example, String str="Hello";  (string literal) or String str="Hel" + "lo";  (string constant expression). What is difference between these String's creations? In Java, the  equals  method can be considered to perform a deep comparison of the value of an object, whereas the  ==  operator performs a shallow comparison. The  equals  method compares the content of two objects rather than two objects' references. The  ==  operator with reference types (i.e., Objects) evaluates as  true  if the references are identical - point to the same object. With value types (i.e., primitives) it evaluates as  true  if the value is identical. The  equals ...

Comparable vs

Classes should implement the Comparable interface to control their  natural ordering . Objects that implement Comparable can be sorted by  Collections.sort()  and  Arrays.sort()  and can be used as keys in a sorted map or elements in a sorted set without the need to specify a  Comparator . « Interface » Comparable + compareTo(Object) : int compareTo()  compares this object with another object and returns a  negative  integer,  zero , or a  positive integer as this object is  less  than,  equal  to, or  greater  than the other object. Use Comparator to sort objects in an order other than their natural ordering. « Interface » Comparator + compare(Object, Object) : int + equals(Object) : boolean compare()  compares its two arguments for order, and returns a  negative  integer,  zero , or a  positive integer as the first argument is  less  than,  ...