Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22
  1. #21
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by ra4king View Post
    Every .class file has it's own String pool?
    So would this be false:
    Java Code:
    class A {
        String hello = "Hello";
    }
    
    class B {
        String hello = "Hello";
    }
    
    class Main {
        public static void main(String args[]) {
            System.out.println(new A().hello == new B().hello);
        }
    }
    No, every single .class file has its own area of literal Strings; the class loader loads these Strings in the single String pool. So your example prints "true". There is a restriction to that single pool: Strings have to be shorter than 64K chars and every single area in a .class file can 'only' contain as much as 65K Strings. (not much of a restriction, but nevertheless ...)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  2. #22
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Location
    Atlanta, Georgia, US
    Posts
    396
    Rep Power
    4

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 7
    Last Post: 04-11-2011, 07:26 PM
  2. Return statements in methods
    By adjit in forum New To Java
    Replies: 12
    Last Post: 03-17-2011, 02:31 PM
  3. Help with simple control statement
    By Kevin BSU in forum New To Java
    Replies: 3
    Last Post: 11-15-2010, 04:27 PM
  4. If Statement return
    By ricardo5222 in forum New To Java
    Replies: 4
    Last Post: 11-01-2010, 11:43 AM
  5. Static Method and Return Statements
    By berelson in forum New To Java
    Replies: 2
    Last Post: 11-29-2008, 11:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •