Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,961 questions

51,903 answers

573 users

How to separate groups of digits in numeric literals with underscore in Java

6 Answers

0 votes
public class Example {
    public static void main(String[] args) 
    {
        long creditCardNumber = 1234_5678_9101_1129L;

        System.out.println("Credit Card Number: " + creditCardNumber);
    }
}
  
  
/*
run:
  
Credit Card Number: 1234567891011129
  
*/

 



answered Jan 8, 2016 by avibootz
edited Aug 1, 2022 by avibootz
0 votes
public class Example {
    public static void main(String[] args) 
    {
        float pi =  3.14_15_92F;
        
        System.out.println("PI: " + pi);
    }
}


  
/*
run:
  
PI: 3.141592
  
*/

 



answered Jan 8, 2016 by avibootz
edited Aug 1, 2022 by avibootz
0 votes
public class Example {
    public static void main(String[] args) 
    {
        long socialSecurityNumber = 555_55_5555L;
        
        System.out.println("Social Security Number: " + socialSecurityNumber);
    }
}
  
  
  
/*
run:
  
Social Security Number: 555555555
  
*/

 



answered Jan 8, 2016 by avibootz
edited Aug 1, 2022 by avibootz
0 votes
public class Example {
    public static void main(String[] args) 
    {
        long hexLong = 0x5F_3A_DE_BD;
        
        System.out.println("Hex long: " + hexLong);
    }
}


  
/*
run:
  
Hex long: 1597693629
  
*/

 



answered Jan 9, 2016 by avibootz
edited Aug 1, 2022 by avibootz
0 votes
public class Example {
    public static void main(String[] args) 
    {
        long hexMaxLong = 0x7fff_ffff_ffff_ffffL;
        
        System.out.println("Hex max long: " + hexMaxLong);
    }
}


  
/*
run:
  
Hex max long: 9223372036854775807
  
*/

 



answered Jan 9, 2016 by avibootz
edited Aug 1, 2022 by avibootz
0 votes
public class Example {
    public static void main(String[] args) 
    {
        byte binByte = 0b0010_0111;
        
        System.out.println("binByte: " + binByte);
    }
}



  
/*
run:
  
binByte: 39
  
*/

 



answered Jan 9, 2016 by avibootz
edited Aug 1, 2022 by avibootz

Related questions

1 answer 148 views
4 answers 305 views
1 answer 150 views
2 answers 203 views
1 answer 184 views
1 answer 191 views
191 views asked Jan 8, 2016 by avibootz
...