Page 5 of 6 FirstFirst ... 23456 LastLast
Results 41 to 50 of 54
  1. #41

    Code:
    Integer a = 100;
    Works in Java. Integer is a wrapper class for primitive type int.

    Code:
    Integer a = 100;
    Integer b = 100;
    so a==b returns true

  2. #42
    Quote Originally Posted by csvarona View Post
    Code:
    Integer a = 100;
    Works in Java. Integer is a wrapper class for primitive type int.

    Code:
    Integer a = 100;
    Integer b = 100;
    so a==b returns true
    Rusty na jud ko sa Java. a==b is indeed true for values below 127. False if Integer a = new Integer(100) pag declare sa a and b. Wala ko kabalo sa explanation nganong dili siya mo work kung above 127. Nalilibog na akoooooo, please explain...

  3. #43
    Haha. Mao jud na ang autoboxing failure sa java. Hopefully, ma-correct ni sa later versions. Masmaayo gihapon ang primitives labi na sa calculations. And if needed jud ang wrappers, dapat .equals gihapon gamiton to compare.

  4. #44
    Naa pud lain JVM based nga languages nga gi-correct na ni nila.

  5. #45
    Autoboxing caches -128 to 127. This is specified in the Java Language Specification. For values between the range of -128 to 127 Java points all the Integer/ int references to the same object to save memory.

    This is not specific to Integer type, it is also visible to other numeric type, Short, Byte, etc. To compare two object if they have the same value, you need to use .equals, comparing object with == means you are comparing the reference, not the value.

  6. #46
    Personal opinion ra to nako diay nga failure siya. Kay wa nalang unta nila gi-introduce kana nga feature. Pero sakto ka nga naa jud sa ilang language specifications.

    And surely dapat ni nila i-correct, apil pud ang performance issues sa wrappers. kay naa ra ba proposal or tsismis nga i-remove sa Oracle ang primitive types para purely object oriented na siya.

  7. #47
    C.I.A. Sarevok's Avatar
    Join Date
    Apr 2007
    Gender
    Male
    Posts
    2,802
    Blog Entries
    4
    Weird lagi sa. So meaning ana 127 ra kutob ang value sa imong Integer na variable? So unsa advantage if mag-gamit ana kesa primitive na int?

  8. #48
    Lapas man, pero unreliable na ang == nga operator if outside sa -128 to 127. Naay wrappers para intuitive ang pag-code (object oriented). Gamit pud siya for Java collections (generics & reflection). Maka-assign pud ka ug null sa wrapper classes. Serializable pud ang mga wrappers.

    Naa pa siguro daghan benefits, pero mao ra ni akong mahinumdoman hahaha.

  9. #49
    C.I.A. Sarevok's Avatar
    Join Date
    Apr 2007
    Gender
    Male
    Posts
    2,802
    Blog Entries
    4
    Nahilom man hehehe new question (nigawas ni sa interview):

    [Programming Language]
    C/C++

    [Question]
    Implement "factorial" (i.e 3! = 3*2*1 = 6) using recursive functions

  10. #50
    C.I.A. Sarevok's Avatar
    Join Date
    Apr 2007
    Gender
    Male
    Posts
    2,802
    Blog Entries
    4
    kay bored ko, ako ning buhion balik

    [Programming Language]
    C/C++ (I think applicable sa tanan)

    [Question]
    Recently naay programming question na nisikat sa interwebs which is this:

    If x is an (binary) integer, what does (x & -x) compute?

  11.    Advertisement

Page 5 of 6 FirstFirst ... 23456 LastLast

Similar Threads

 
  1. what is your favorite programming language?
    By sachem in forum Programming
    Replies: 310
    Last Post: 10-08-2015, 03:11 PM
  2. Python programming questions
    By Louis in forum Programming
    Replies: 8
    Last Post: 09-10-2014, 10:51 AM
  3. Beware of 'tricked out' Hijack program
    By cliff_drew in forum Software & Games (Old)
    Replies: 4
    Last Post: 06-24-2009, 02:38 PM
  4. Boot using USB w/ different programs (question)
    By babolgam in forum Computer Hardware
    Replies: 5
    Last Post: 01-22-2009, 11:17 AM
  5. question on networking programming
    By poymode in forum Programming
    Replies: 6
    Last Post: 12-29-2008, 08:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top