Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22
  1. #21
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power


    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,

    Build a wall around Donald Trump; I'll pay for it.

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

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, 03:31 PM
  3. Help with simple control statement
    By Kevin BSU in forum New To Java
    Replies: 3
    Last Post: 11-15-2010, 05:27 PM
  4. If Statement return
    By ricardo5222 in forum New To Java
    Replies: 4
    Last Post: 11-01-2010, 12:43 PM
  5. Static Method and Return Statements
    By berelson in forum New To Java
    Replies: 2
    Last Post: 11-30-2008, 12:17 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