Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 4th, 2014, 05:30 AM
Registered User
 
Join Date: Dec 2014
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default RuntimeException error with code

Need help with basic java code

Hi guys. I need some help on this code. It compiles and I can get results when I run it on Netbeans but I always get RuntimeException.
How can I get rid of it? Any thoughts? Thanks!

Code:
// i++
        float Etplus, TrueEplus, TrueVplus, fplus1=0;
        //  Summation from i=1 to 10000
        for (int i=1;i<=10000;i++){
            fplus1 +=(float) 1/(Math.pow(i,4));
        }
        TrueVplus = (float) ((Math.pow(Math.PI, 4)) / 90);
        TrueEplus = (float) TrueVplus - fplus1;
        Etplus = (float)(TrueEplus/TrueVplus)*100;
   
        JOptionPane.showMessageDialog (null,"Ft(i++) = "+TrueVplus + "\n\nFa(i++) = " +fplus1 + "\n\nEt(i++) = ("+Etplus+ ")%","Results for i++ (Float)", JOptionPane.INFORMATION_MESSAGE);
       
        // i--
        float Etminus, TrueEminus, TrueVminus, fminus1=0;

        //  Summation from i=10000 to 1
        for (int j=10000;j>=1;j--){
            fminus1 += (double) 1/(Math.pow(j, 4));
        }

        TrueVminus = (double) (Math.pow((Math.PI), 4))/90;
        TrueEminus = (double) TrueVminus - fminus1;
        Etminus = (double) (TrueEminus/TrueVminus)*100;
        
        JOptionPane.showMessageDialog (null, "Ft(i--) = "
+TrueVminus + "\n\nFa(i--) = " +fminus1 + "\n\nEt(i--) = (" +Etminus+")%","Results for i--(Float)", JOptionPane.INFORMATION_MESSAGE);

 }

}
 
Old December 6th, 2014, 02:18 AM
Registered User
 
Join Date: Dec 2014
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey just found out that RuntimeException is the superclass of those exceptions that can be thrown during the normal operation of the Java Virtual Machine... Any ideas how to get rid of this issue? Thanks!
 
Old December 6th, 2014, 03:53 AM
Registered User
 
Join Date: Dec 2014
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you post the full stack trace for the that error nick? It would be great that you would post that so that we can help you solve it quickly.
 
Old December 10th, 2014, 02:00 AM
Registered User
 
Join Date: Dec 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey there are various types of ExceptionHandling present in Java, but it depend on the program whether its access from base class or the derived class.
For more details visit http://www.koolchart.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 2 - p48 Activity3 java.lang.RuntimeException wel51x BOOK: Beginning Android Application Development 0 December 27th, 2011 02:47 AM
Ch. 4 MyView RuntimeException jimw BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 4 July 28th, 2009 12:37 PM
java.lang.RuntimeException: System properties file mshah101 Apache Tomcat 1 November 22nd, 2007 12:17 AM
Code Error luismalave BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 June 13th, 2007 01:54 PM
Error displayed with error trap code stoneman Access 4 February 28th, 2004 02:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.