-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,183
  • 2
  • 20
  • 39
Sad Dam
  • 105
  • 1
  • 2

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
  • 155,977
  • 14
  • 207
  • 269
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
  • 12