-1

public class Methods {

public static void main(String[] args) {

    int myNum = myNumber();
    System.out.println(myNum);

}   
static int myNumber(){
    return 03233574633;
}

}

When I call a method to display my phone number on screen, it display something this 443480475..

Why is this happening in Java Programming.. Please help

mithrop
  • 3,283
  • 2
  • 21
  • 40
Sad Dam
  • 145
  • 1
  • 3

2 Answers2

3

The 0 prefix means that 03233574633 is an octal number which equals 443480475 decimal. You can use a String to represent the phone number.

Reimeus
  • 158,255
  • 15
  • 216
  • 276
2

Starting a literal number with a 0 makes it base 8 (octal). You want base 10. You can easily store your phone number as a String to avoid this.

BoDidely
  • 504
  • 3
  • 13