Internal method working of java