.class error

Hi,
I am trying to make a simple code where a main program calls a method in a class so that the total sum of all elements of an array is calculated. Here is my code:
public class playingwithArrays
        static void sumArray(int [] arr){
            int sum = 0;
                for(int i = 0; i<arr.length; i++){
                    sum+= arr;
System.out.println ("Total sum of array is" + sum);
This is the class where there is the method i want to access
The class below is the main class:public class Start
public static void main (STring[] args){
int [] arr = new int [10];
for (int i; i<arr.length; i++){
arr[i] = (i+1);
playingwithArrays summation = new playingwithArrays ();
summation.sumArray(int arr[]);
Where there is bold the compiler is giving me a .class error. Please can you help me as I am a beginner and I am trying to learn java!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

It's a good idea to follow standard conventions about nAmEs. PlayingWithArrays, not playingwithArrays.
You define sumArray() as a static method. That means that it will not be associated with a particular instance of the PlayingWithArrays class. And so you can access it without having to create a new instance of the class.
It's not actually wrong to say summation.sumArray(...), it's just that it looks odd. It would better be PlayingWithArrays.sumArray(...).
The actual error is what you are passing as the argument. This method expects an array of int and that's what you should pass it. You don't need the int and [] business that goes into the declaration of a method, just use the variable.
PlayingWithArrays.sumArray(arr);This will use a static method of the PlayingWithArrays class to print out the sum of the array elements.

Similar Messages

  • Plug-in load class error while running portalapp.xml file in NWDS7.0

    hi,
    im facing a problem in NWDS7.0 while running portalapp.xml file im getting error realted some plug-in load class error.
    Even 3 times i have re-installed but still getting same error.
    Please help me how to over come this. This is error im getting :
    Please open this link with Firefox so that you can able to see error.
    http://www.imageurlhost.com/images/jri5lj7lpftu23ejyye0_Error.jpg
    Regards,
    prasad.

    Dear Prasad
    Please right click on portalapp.xml > open with > check all the available editors.
    Also restore default edition in NWDS. Go to windows > preference > Workbench OR Web editors > click on restore default and Apply and then Ok.
    then close the NWDS and open it.
    Hope it will helps
    Best Regards
    Arun Jaiswal

  • Import and recognize class error

    The following is a simple welcome.jsp file that I am trying to run on a local J2EE sever. As you can see it tries to import classes one being the FaqCategories.class which is located in the folder Ch03 of the WEB-INF directory. When I call the page up on the browser It gives me that it does not recognize the FaqCategories faqs = new FaqCategories; class error. I am wondering why(Is the import statement wrong? Did I put the class in the wrong directory? Etc... I followed everything the book told me to a que and I still received an error.
    <&@ page errorPage="/WEB-INF/errorPage.jsp"
             import="java.util.Iterator,Ch03.FaqCategories" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
         <title>Java FAQ Welcome Page</title>
       </head>
       <body>
         <h1>Java FAQ Welcome Page</h1>
         Welcome to the Java FAQ
      <%! FaqCategories faqs = new FaqCategories(); %>
      Click a link below for answers to the given topic.
      <%
        Iterator categories = faqs.getAllCategories();
        while(categories.hasNext()) {
           String category = (String) categories.next();
       %>
          <p><a href="<%= replaceUnderscore(category) %>.jsp"><%= category
       %></a></p>
       <%
        %>
       <%@ include file="/WEB-INF/footer.jspf" %>
          </body>
         </html>
          <%!
           public String replaceUnderscore(String s) {
             return s.replace(' ','_');
           %>

    Originally posted by: nadeem.aboobaker.bea.com
    "Walter Harley" <[email protected]> wrote in message
    news:f2jet7$na1$[email protected]..
    > "Nadeem Aboobaker" <[email protected]> wrote in message
    > news:f2j2au$fi6$[email protected]..
    >> Hello all,
    >>
    >> I am having issues creating a plugin as a JAR file, where the plugin
    >> contains a nested JAR file.
    >
    >
    > Hey, Nadeem.
    >
    > Yes, there are a lot of problems with trying to use nested jars in (and
    > out of) Eclipse. You can look at
    > https://bugs.eclipse.org/bugs/show_bug.cgi?id=145001 as a sort of
    > "umbrella" bug report that mentions some of the issues and refers to other
    > bugs. There is more than one limitation at work, so describing the issues
    > succinctly is difficult. As you noticed in the posting from a year ago,
    > the only way to make it work really smoothly is to get rid of the nested
    > jars by expanding them (and even then, there are issues with nested .class
    > files!).
    >
    > If it is at all possible to convert the nested .jar into a separate
    > plug-in (by adding an OSGi-compliant MANIFEST.MF) and make your primary
    > plug-in depend on it, instead of trying to nest the jar within your
    > primary plug-in, that will be your best and most "Eclipse-friendly"
    > answer.
    >
    > Feel free to contact me offline or here on the newsgroup if needed.
    >
    > -walter
    Walter, thanks for the reply. Converting the nested .jar into a sepearate
    plug-in isn't possible for my case. I checked out the Bug report, and also
    the referenced bugs and Wiki page, it was interesting to read all the
    issues. :) In any case, I know that deploying the plugin as a directory
    instead of a jar works, so I will just go with that approach.
    - Nadeem

  • Org.apache.jasper.JasperException Ambigous Class Error

    I included two classes:
    <% @page import = "com.myco.ejb.ThisBean" %>
    <% @page import = "com.myco.ejb.session.ThisBean" %>
    and received an org.apache.jasper.JasperException Ambigous Class Error on the second import. One is a cmp bean, the other is a session bean. I thought Sun wanted us to name our packages like this to aid in the prevention of duplicate class names (i.e., Windoz DLLitus). Shouldn't these classes be unique by the package name?

    No, that's not redundancy. Are you using the fully qualified class name in your jsp:usebean tags?
    like:
    classname="com.mypackage.mybeans.MyBean"
    And are you using the package statement properly in your source?
    In the case that you are using two classes of the same name in one file the compiler has to have a means of distinguishing between the two. The only way for it to do so is to use the fully qualified name of the class in each case in which it is referenced. This means either in the jsp:usebean tag as shown above, or in such a case as:
    com.mypackage.myclasses.MyClass theOb=new com.mypackage.myclasses.MyClass();
    Awkward yes, but ambiguous No.
    In the case where you are using only one class of a given name the import statement will be sufficient for the compiler to know that it is that which you fully qualify in the import statement.
    Remember, all that the import statement does is provide the convenience of pre-clarifying exactly which class you'll be referring to when using the abbreviated class name only. Importing two classes of the same name defeats the purpose.
    Good luck,
    Brad

  • Retriving com class error in add-on client machine

    Dear all,
    i got error com class error when i start the add-on. The add-on working good all  systems except two client system.
    Thanks & Regards
    B.Lakshmi narayanan

    hi you  checked..
    Check it search .
    May be the problem in X86  platform..
    Retrieving the COM class factory for component with CLSID

  • Missing Class error from handler class - urgent question!

    Hi,
    I am getting an "Missing Class" error when running a web service. The web service was generated from a Java class via the "create J2EE web service" option.
    The web service has a JAX-RPC handler class added, which belongs to the same package as a logging class. The logging class is used to write to a file for debug purposes. A "missing class" error is being generated whenever I attempt to invoke the web service (via the enterprise manager test util), the error refers to the logging class which is used by the main handler class. The JAX-RPC handler works fine by itself, the error is only seen when I attempt to use the logging class.
    I have re-built, re-deployed from scratch again, but still get the same error! Am I missing something simple here?
    thanks for any advice

    Hello,
    I have posted something similar, but I am not sure how to get over this issue. I am not sure if this is a code issue, I have scanned both EJB 2.0 and 2.1 specifications, but nothing caught my eye.
    Here is the error I am getting starting this in JDeveloper 1013 :
    Apr 11, 2006 12:17:49 AM com.evermind.server.Application setConfig
    WARNING: Application: current-workspace-app is in failed state as initialization failedjava.lang.InstantiationException: Error initializing ejb-modules: [current-workspace-app:CNSI-JDev-7_Exp-7_0:DbUtilWrapper] - Unable to load ejb-class com.my.common.database.ejb.DbUtilWrapperBean, see section 23.2 of the EJB 2.1 specificationjava.lang.ExceptionInInitializerError: java.lang.NullPointerException
    Here is the ejb-jar.xml :
    <session>
    <description>Session Bean ( Stateless )</description>
    <display-name>DbUtilWrapper</display-name>
    <ejb-name>DbUtilWrapper</ejb-name>
    <home>com.my.common.database.ejb.DbUtilWrapperHome</home>
    <remote>com.my.common.database.ejb.DbUtilWrapper</remote>
    <local-home>com.my.common.database.ejb.DbUtilWrapperLocalHome</local-home>
    <local>com.my.common.database.ejb.DbUtilWrapperLocal</local>
    <ejb-class>com.my.common.database.ejb.DbUtilWrapperBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    I am not sure if this should be in the assembly-descriptor, in ejb-jar.xml or orion-ejb-jar.xml :
    <method-permission>
    <unchecked/>
    <method>
    <ejb-name>DBUtilWrapper</ejb-name>
    <method-name>*</method-name>
    </method>
    </method-permission>
    Any ideas ?
    Thanks

  • Go to Java Class Error

    When I highlight a keyword or class and right click to
    'Go to Declaration' or 'Browse Javadoc' I get:
    Go to Java Class Error
    Unable to determine browse target.
    Help
    Thanks

    Hi! Welcome to the forums.
    Try reading this post.
    http://supportforums.blackberry.com/t5/BlackBerry-World/solution-on-isssues-with-Facebook-for-BlackB...
    Cheers!
    Click " Like " if you want to Thank someone. If Problem is resolved accept it as a "Solution ", so that others can make use of it.
    Click if you want to Thank someone. If Problem is resolved, so that others can make use of it.

  • "Missing Class" error when running web service

    Hi,
    I am getting an "Missing Class" error when running a web service. The web service was generated from a Java class via the "create J2EE web service" option.
    The web service has a JAX-RPC handler class added, which belongs to the same package as a logging class. The logging class is used to write to a file for debug purposes. A "missing class" error is being generated whenever I attempt to invoke the web service (via the enterprise manager test util), the error refers to the logging class which is used by the main handler class. The JAX-RPC handler works fine by itself, the error is only seen when I attempt to use the logging class.
    I have re-built, re-deployed from scratch again, but still get the same error! Am I missing something simple here?
    thanks for any advice

    Cant you paste some of your code, formatted in code tags? It looks like there is a problem passing some of the XMl response, it doesnt like a tag html.
    If you post some code somebody might actually be able to help you.

  • Invalid change to class error when deploying EJB

    We have EJBs that were built by Webgain Visual Cafe and successfully deploy
    to WLS 5.1. We then use the WLE EJB Deployer Tool to build WLE container
    classes and deploy the same EJBs in WLE 5.1.
    One EJB does not deploy in WLE. The ULOG error message is:
    133929.EA-LAWSTUC!JavaServer.517: main: IJENGINE_CAT:150: ERROR: Invalid
    change to class service.Request
    133929.EA-LAWSTUC!JavaServer.517: main: EJB_CAT:29: ERROR: While deploying
    jar ServiceEJB : com.beasys.weblogic.classloader.RedeploymentException:
    ERROR: Invalid change to class service.Request
    133929.EA-LAWSTUC!JavaServer.517: Finalizer: IJENGINE_CAT:152: INFO: Closing
    jar C:\aj\ServiceEJB_WLE.jar
    Does anyone know what can cause an "invalid change to class" error when
    deploying to WLE 5.1? Especially since the EJB deploys successfully in
    WLS.
    Carl Lawstuen

    Reason: database keeps a reference of the class in JAVA$CLASS$MD5$TABLE table. This table keeps a refrence to all java classes loaded in database, and is present in each schema you deploy classes. That's the reason why if you change the application module name, you can load this classes. It instead keeps a reference if you use DROP JAVA CLASS command to drop a java class from de database. Use DROP JAVA command to clear the reference of the dropped classes when dropping it.
    You can see this table as a class dictionary of the database, and you don't have to handle this records manually.

  • Class error message

    I get an error message when I boot up Livetype:
    An unexpected error occured. (*class error for 'ProSystemStore;' class not loaded)
    When I hit continue on the error message Livetype opens but when I select "New" under File the app quits. Any ideas other than reloading the app?
    thanks,
    Rob
    G5 Mac   Mac OS X (10.4.5)  

    sorry, I can't duplicate your duplicative post. the error appears ot be a unix command or a Java thingy but I cannot find any such item on my system. I can finds tons of "class" files and several with "pros" in the filoename but none with "prosystem"
    Hope you get better advice.
    bogiesan

  • Duplicate class error message

    Hi,
    Does anyone know what a duplicate class error message means and how to resolve it?
    It just does not make any sense to me as there is only one instance of the class yet the compiler is throwing out a duplicate class error message.

    I copied your experiment and had no trouble compiling the four classes (A, B, C, and Test). One thing to note is that Test.class shows up in the root destination directory (above a.b.c) because Test.java is missing the package statement. Perhaps, as mentioned earlier in the thread, the missing package statement is causing the problem with your compiler.
    I compiled them with ant using the following build.xml code:
    <?xml version="1.0" encoding="UTF-8"?>
    <project basedir="." default="compile" name="PackageTest">
         <property name="build.dir" location="build"/>
         <property name="dist.dir" location="dist"/>
         <target name="init">
              <mkdir dir="${build.dir}/classes"/>
              <mkdir dir="${dist.dir}"/>
         </target>
         <target name="compile"
                   depends="init"
                   description="Compile Source Code">
              <javac srcdir="."
                   destdir="${build.dir}/classes"/>
         </target>
    </project>

  • Nokia C3 Java Class Error

    Hi all,
    I have just upgraded my Nokia C3 to latest software update. 
    After this whenever iopen any application (e.g. ebuddy or rocket talk) it shows java class error not found & asking me to delete some items. 
    I checked my memory the Memory card has 1 gb Free space then why should it ask to free memory
    someone having faced this issue kindly assit.
    currently unable to open any application that i download from net.
    regards,
    thads

    HI,
    Can you try restore factory settings?
    Plese remember to backup you phone's data.
    If your application you installed before is not working, uninstall them and install again.
    I hope this helps.
    Br
    Mahayv

  • Cannot lauch project, class error messages

    The project was originally configured in LookoutDirect, then converted to Lookout 6.2.
    One one computer I have a seperate Runtime and Development packages.  This computer has been working satisfactoraly for two months.
    Insatlled second runtime software on computer two, but cannot launch project because of class errors.
    Can I copy the entire National Instrument folder from one computer to the other to correct this.
    thanks
    John Peterson
    Solved!
    Go to Solution.

    Problem solved
    Believe drivers are DSComm4.cbx and Meter4.cbx, but don't bother moving them.  Tried every conceivable location.
    You must INSTALL the driver on both computers.Driver from Automation Direct (PC-DL-PLUS LOOKOUT DIRECT PLUS DRIVER OBJECT SFTWRE)
    From the responses I think their is more than one with the problem.
    Also make sure the tages are not pointing to the computer name.  Tag path should start with "..\" or "..\..\" (test on yours) to work on both computers.  Computer name appears depending on how you drill down to the PLC address.  This doesn't stop the project, just gets rid of the red X's on the second computer. 
    Thanks for your responses
    John Peterson 

  • Generic Class Errors continue

    Hi have had "generic class" errors with my printers on my MacPro for over two years now. First with a Samsung and now with a Brother printer. I have the latest drivers for the Mac, I have the latest Leopard and I still get these really annoying errors that require restarting everything. I had the problems with Tiger too.
    Is there any way to avoid this kind of mess?
    Any help appreciated.

    kittireddy wrote:
    What is "Generic class" in Java? and what's use of that?It's just added to confuse new programmers.
    Give me an idea with an exampleNo problem:
    public class GenericsExample {
        public static void main(String[] args) {
            new X<String>(new X<String>("Y"));
    class X<Y> {
        Y x;
        X(Y y) { x = y; }
        X(X<Y> y) { System.out.println("y.x = "+y.x); }
    }

  • Eclipse Plugin Creation - "Plug-in name was unable to load class " error

    Hi everybody and happy new year to you all,
    i got a little problem again. I have written the first lines of code of my plugin and wanted to test it (run as Eclipse Application). I got the following error-msg, when clickin either on the menu item or toolbar button:
    "Could not create action delegate for id: org.eclipse.tui.inpulse.actions.InpulseStart
    Reason:
    Plug-in org.eclipse.tui.inpulse was unable to load class org.eclipse.tui.inpulse.InpulseStart."
    My project has the following properties (of which i read they are important):
    Source folder: org.eclipse.tui.inpulse/src
    Output folder: org.eclipse.tui.inpulse/bin
    Dependencies: org.eclipse.ui, org.eclipse.core.runtime
    Extensions: org.eclipse.ui.actionSets
    ExtensionsPoints: none
    The following is my plugin xml:
    <plugin>
       <requires>
              <import plugin="org.eclipse.core.resources"/>
            <import plugin="org.eclipse.ui"/>
        </requires>
        <runtime>
              <library name="Inpulse.jar"/>
        </runtime>
        <extension
              id="org.eclipse.tui.inpulse.InpulseActionSet"
              name="org.eclipse.tui.inpulse.InpulseActionSet"
              point="org.eclipse.ui.actionSets">
            <actionSet
                id="org.eclipse.tui.inpulse.InpulseActionSet"
                label="Inpulse"
                  visible="true"
             description="The action set for the Eclipse Hello World example">
             <menu id="org.eclipse.tui.inpulse.InpulseMenu" label="Inpulse">
                   <separator name="samples"/>
             </menu>
             <action id="org.eclipse.tui.inpulse.actions.InpulseStart"
                   menubarPath="org.eclipse.tui.inpulse.InpulseMenu/samples"
                   toolbarPath="Normal"               
                   label="Inpulse"
                   tooltip="Start pattern search."
                   class="org.eclipse.tui.inpulse.InpulseStart"/>
            </actionSet>
       </extension>
    </plugin>The javafile "InpulseStart.java" is in the "org.eclipse.tui.inpulse" package and has the first line "package org.eclipse.tui.inpulse;". The class "InpulseStart" implements "IWorkbenchWindowActionDelegate".
    So the following members are implemented:
    public void run(IAction proxyAction){...};
    public void selectionChanged(IAction proxyAction, ISelection selection){...};
    public void dispose(){...};
    //and some additional ones ;-)I really dont know what i do wrong. If you have an idea, what i just miss out or do wrong, id be glad if you helped me out!
    Cya

    Aye, you are right, i should/could have posted this somewhere else. I just hoped, that i can get a good answer here, cause ppl helped me out very nice before.
    Im sorry if i offended users of this forum...
    The "advice" is recognized and i will post somewhere else in case i have a eclipse specific problem.

Maybe you are looking for

  • Firefox is not working after upgade to vesion 4

    I have Windows XP installed on my PC toshiba satelit 200 serie, I use french version firefox, After instalation of the new fiefox 4 it's not working (but Googole Chrome and IE are O.K.)

  • GT 660Ti power

    Hi all, I have bought this video card ( GTX660 TI 2GB ), but having a problem now, I am running Dual head, but this card has only one option to go to VGA, i have tried to use the DVI-D to VGA connector , that wont work. I have bought a Displayport to

  • Acl in class-map

    Hi i'm a little unsure of how using ACL's works within a class map. I want to allow access to a web server 1.1.1.1 and deny all othetraffic coming from the outside zone to the inside zone, so i have created an acl with a permit http to 1.1.1.1 and a

  • Select Expert

    When using the Record Selection tool from the Standard report creation wizard, the drop down list in the Record select is not being populated with data. However, when using the select expert from a blank report the drop down is working just fine. Any

  • [svn] 3305: Change visibility of messageHandler(event:MessageEvent): void from private to protected.

    Revision: 3305 Author: [email protected] Date: 2008-09-22 17:44:38 -0700 (Mon, 22 Sep 2008) Log Message: Change visibility of messageHandler(event:MessageEvent):void from private to protected. Bug: NA QA: No Doc: No Checkintests Pass: Yes Modified Pa