Full width home advertisement

Java

Tech News

Ad

  1. package clgPracticals;
  2.  
  3.  
  4. class Pr2 {
  5. public static void main(String[] args) {
  6. try { // using try to handle ArrayIndexOutOfBoundsException
  7. double pi, r, ans;
  8. pi = 3.14;
  9. r = Integer.parseInt(args[0]);
  10. ans = pi * r * r;
  11. System.out.println("Area Of circle " + ans);
  12. } catch (ArrayIndexOutOfBoundsException e) { // this block will handle Exception
  13. System.out.println("Please give a command line argument before running");
  14. }
  15. }
  16. }
  17.  

No comments:

Post a Comment

Bottom Ad [Post Page]