java run time error

java run time error

when i compile my program it didnt show any error in my program.but i cant run my program, if i run my program means it will show error like as following
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Armstrong.main(Armstrong.java:22)
Java Result: 1
any one can know what is the solution for this
View Answers

March 8, 2010 at 4:01 PM

Hi Friend,

Exceptions always occurs at runtime. ArrayIndexOutOfBoundsException occurs when you try to access an item in an array which either doesn't exist or is outside the length of the array.

IF you want to check whether the entered number is armstrong or not then try the following code:

import java.io.*;
class Check{
public static void main(String[] args) throws Exception {
System.out.print("Enter number to check:");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String input = reader.readLine();
int num=Integer.parseInt(input);
int i = num;
int number=0,remainder;
while(num > 0){
remainder = num % 10;
number = number + (int)Math.pow(remainder,3);
num = num / 10;
}
if(number == i){
System.out.println(i+" is an Armstrong Number");
}
else{
System.out.println(i+" is not a Armstrong Number");
}
}
}

Thanks









Related Tutorials/Questions & Answers:
java run time error - JDBC
java run time error  when i m running for batch execution program in jdbc i m facing this kind of runtime error as Exception in thread "main" java.sql.SQLException: Io exception: The Network Adap ter could not establish
java run time error in loading the driver - JDBC
java run time error in loading the driver  when i mrunning the program in oracle using type 4 driver it is giving the error as Error:jdbc.driver.OracleDriver the code was as follows: please suggest me how it can
Advertisements
java run time error - Java Beginners
java run time error  when i compile my program it didnt show any error in my program.but i cant run my program, if i run my program means it will show error like as following Exception in thread "main
java run time error - Java Beginners
java run time error  i am getting error "main... only, i have to display number of files and its last modified time ,i use... 23 08:17 0 23 08:17 but after displaying 12 such lines, it show error
java applet run time error - Applet
java applet run time error  Hi, Im new to java applet.please help me. i have create a MPEG movie player in applet. when i run that program it show the error that,"javax.media.NoPlayerException: Error instantiating class
error in java progran at run time - Java Beginners
error in java progran at run time  Hello sir,,, i make a servlet program in java,,but i face some problem,,so please me.. Actually this type of error are come in my all servlet program My Servlet-- Error
error in java progran at run time - Java Beginners
error in java progran at run time  Hello sir,,, i make a servlet program in java,,but i face some problem,,so please me.. Actually this type of error are come in my all servlet program My Servlet-- Error
run time error
run time error  my program compile successfully but does not showing... saved your class with HelloWorld. Check it out. Even then if error occurs, post the error.   Here it works and showing output. Have you save the file
Run time error - WebSevices
Run time error  Hello, Anyone know, how run the template files in zend framework.Anybody help me. Rgds, Pras  code to help in solving the problem : protected function _run($template
jdbc run time error - JDBC
jdbc run time error  i m creating the table using thin driver it is showing the following run time error: Exception in thread "main" java.lang.ClassNotFoundException: jdbc.oracle.OracleD river
Java run time polymorphism
Java run time polymorphism  What is run-time polymorphism or dynamic method dispatch
run ttime error - Java Beginners
run ttime error  how to compile a client server application using RMI ?  Hi friend, I am sending you a link. This link will help you. Please visit for more information. http://www.roseindia.net/tutorials/rmi/rmi
objects create at run time - Java Interview Questions
objects create at run time  how to create objects at runtime,other than instantiation.  Hi friend, Object : Objects are the basic run time entity or in other words object is a instance of a class . An object
java code to insert select at run time....????
java code to insert select at run time....????  java database code...;/html> 2)edit.jsp: <%@page language="java"%> <%@page import... the application Java Swing then Visit Here   You can also visit
when I run exiting project that time I got error, I want solution on it?
when I run exiting project that time I got error, I want solution on it?  Error occurred during deployment: Exception while loading the app... log for details. BUILD FAILED (total time: 1 minute 20 seconds
Run time exception
Run time exception  What class of exceptions are generated by the Java run-time system?  Java runtime system generates RuntimeException and Error exceptions
Java compile time error. - Java Beginners
Java compile time error.  CreateProcess error=2, The system cannot..., Please specify in detail and send me code. If you are new java... : http://www.roseindia.net/java/master-java/index.shtml Thanks & Regards
Run time polymorphism
Run time polymorphism  What is run time polymorphism or dynamic method dispatch
Java error code
Java error code       Java Error code are the set of error that occurs during the compile-time and Run-time. From java error we have given  you
get integer at run time
get integer at run time  how to get integer value at run time in j2ee using servlets   Hi, You can get the value from request parameter and then convert using the function Integer.parseInt(variable).ADS_TO_REPLACE_1
Run time problem
Run time problem  when i run a project,it shows an exception like "unable to create MIDlet".It also shows "running with locale:English_united States.1252 running in the identified third party security domain" "please help
java run time textfield and use with map - Java Beginners
java run time textfield and use with map  i want to program which read data from file and store in map and display in different textfields which are generated at run time like a text file store information class a1
JSP handle run-time exceptions
JSP handle run-time exceptions  How does JSP handle run-time exceptions?   You can use the errorPage attribute of the page directive to have uncaught run-time exceptions automatically forwarded to an error processing
Compile time error
Compile time error  Hi, When i compile my simple program in cmd am getting a error like "Javac is not a recognized as an internal or external...; This means java is not configured properly in your system. Please visit
How to find run time in SQL.
How to find run time in SQL.  I have 10 backend jobs in sql which runs at different time intervals. Sample data is shown below Table name:- Job_Run... 22/10/2010 17:30:00ADS_TO_REPLACE_1 I want to find the run time of both the jobs
compile time error
compile time error  my program compile successfully and make the class file also but when i tried to do next command to see the output,it showing error that "could not find or load main class fibbo" fibbo is my class name
compile time error
compile time error  my program compile successfully and make the class file also but when i tried to do next command to see the output,it showing error that "could not find or load main class fibbo" fibbo is my class name
compile time error
compile time error  my program compile successfully and make the class file also but when i tried to do next command to see the output,it showing error that "could not find or load main class fibbo" fibbo is my class name
Java Error in Bus Time Table Project - Development process
Java Error in Bus Time Table Project  Please Solve Errors import... JTabbedPane(); l1=new JLabel("Bus No:"); l2=new JLabel("Source:"); l3=new JLabel("Time(hh:mm:ss):"); l4=new JLabel("Destination:"); l5=new JLabel("Time(hh:mm:ss
How to stop java scripting engine when the script being run is taking too much time?
How to stop java scripting engine when the script being run is taking too much time?   How to stop java scripting engine when the script being run is taking too much time? for e,g, in case of infinite loop the memory is getting
Exceptions in Java
the normal execution of Java program. In case of Run-time error, if you divide...; Introduction Exception is a run-time error which arises during... follow the rule, this will give you Compile-time error. 2.Run -time Error-Run-time
Threads(suspend(),resume()) run time abnormal behaviour
Threads(suspend(),resume()) run time abnormal behaviour   class...=new Thread(this); t.start(); } public void run..."); a1.t.resume(); } } hi! when i run this code after some seconds
Jsp error when i run this a jsp file
Jsp error when i run this a jsp file  hi I got this error when i run the jsp file in IDE and outside also please help me java.lang.NullPointerException org.apache.jsp.insertjsp.jspInit(insert_jsp.java:22
Grid World project Run Error !! help please!!
Grid World project Run Error !! help please!!  i'm trying to make... occurs and i exit the error but run does not work anymore) (adsbygoogle... not "run" here is my code: import info.gridworld.grid.Location; import
Data transfer object at run time - Development process
Data transfer object at run time  I have to assign data from resulset to data transfer object.. but i don't know the the number of coloums in selected table. So i have creted a Data Object class with 100 getter setter methods
i cant find any compile time error but there is runtime error.
i cant find any compile time error but there is runtime error.  ...){ System.out.println("Error:connection not created"); } ADS_TO_REPLACE_1... copy and run it on your computer. import java.sql.*; public class JDBCExample
Version of jsf-extensions>jsf-extensions-run-time dependency
List of Version of jsf-extensions>jsf-extensions-run-time dependency
Maven Dependency jsf-extensions-run-time >> 1.0.4
You should include the dependency code given in this page to add Maven Dependency of jsf-extensions >> jsf-extensions-run-time version1.0.4 in your project
Run time Exception after Clean and Build JavaNetBeans Project
Run time Exception after Clean and Build JavaNetBeans Project  I have... problem when i run it in NetBeans using Run Main Project Button. Then i 'Clean... The PROBLEM IS... When is run the jar file from the dist folder , the first form (i.e
Java error
Java error  class WhileLoopMethod{ public static void main(String args[]){ new Hello(); } } class Hello{ int a = 5, b = 88; while(a } //it is giving compile time error .....illegal start
Java error
Java error  class WhileLoopMethod{ public static void main(String args[]){ new Hello(); } } class Hello{ int a = 5, b = 88; while(a } //it is giving compile time error .....illegal start
can i know the error in this code... am unable to run this code
can i know the error in this code... am unable to run this code  class DemoArray { public static void main(String args[]) { int arr[]={12,13,14,15}; int n=arr.lenght; System.out.println("length of array:"+n); for(int i=0;i
Maven Repository/Dependency: jsf-extensions | jsf-extensions-run-time
Maven Repository/Dependency of Group ID jsf-extensions and Artifact ID jsf-extensions-run-time. Latest version of jsf-extensions:jsf-extensions-run-time dependencies. # Version Release Date
best os to run java
best os to run java  which is best os to run java program
how to run - Java Beginners
how to run   how to run java program... brifely  Hi Friend, Java Virtual Machine is responsible for running java program.Java uses... to execute or run the program. For ex, If you have the following java program
java not run on my pc
java not run on my pc  i have installed java in pc but when i run and compile any program the massage is display that 'javac' is not recognized as an internal or external command
compile and run java program
compile and run java program  Hello, everyone!!! I just want to ask if you anyone here knows how to compile java file in linux specifically UBUNTU. For example, I have a java file named Hello.java and saved at my desktop.ADS
how to run java program
how to run java program  i have jar file. in jar i have so many classes.in one of file i want modify .after modifying file i want replce in jar. please help me to how to generate class and how to replace
java pages run
java pages run  how do we run jsp file in the browser. do we need to install server. could it be run on the xamp server   You need Apache Tomcat Server to run the jsp code over it. Follow these steps to run the simple
run a java application - Java Beginners
run a java application  Hai Deepak, I ve set my environment...$1.class,SwingDemo$2.class.But i couldnt run my file.During run time it gives... run any java file.So i want to know the problem actually i had.Thanks in advance

Ads