Need help understanding a line of code from the Java Tutorial

Here is the code I have seen in the Reflection Tutorial:
import java.lang.reflect.*;
class SampleInvoke {
   public static void main(String[] args) {
      String firstWord = "Hello ";
      String secondWord = "everybody.";
      String bothWords = append(firstWord, secondWord);
      System.out.println(bothWords);
   public static String append(String firstWord, String secondWord) {
      String result = null;
      Class c = String.class;
      Class[] parameterTypes = new Class[] {String.class};
      Method concatMethod;
      Object[] arguments = new Object[] {secondWord};
      try {
        concatMethod = c.getMethod("concat", parameterTypes);
        result = (String) concatMethod.invoke(firstWord, arguments);
      } catch (NoSuchMethodException e) {
          System.out.println(e);
      } catch (IllegalAccessException e) {
          System.out.println(e);
      } catch (InvocationTargetException e) {
          System.out.println(e);
      return result;
}There are 2 lines I do not understand (but once I understand one, I'll understand the other).
Here they are:
Class[] parameterTypes = new Class[] {String.class};
Object[] arguments = new Object[] {secondWord};Any explanation will be greatly appreciated :)

There are 2 lines I do not understand (but once I
understand one, I'll understand the other).
Here they are:
Class[] parameterTypes = new Class[]
{String.class};
Object[] arguments = new Object[]
{secondWord};
the first line simply creates an array of objects, the objects are of type Class. It then places the object referenced in the brackets into the array.

Similar Messages

  • Trouble running sample code from the java trails

    I'm trying to run Sun's DocumentEventDemo available on the trails. I can get it to compile successfully but I get several errors when I try to run it. After compiling the source, this is what I get when I try to run it:
    C:\listen>java -cp . DocumentEventDemo
    Exception in thread "main" java.lang.NoClassDefFoundError: DocumentEventDemo (wr
    ong name: events/DocumentEventDemo)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    The source is available from the java trails using the name DocumentEventDemo
    Thanks
    ~Sklave

    actually that is really helpful. My directories are most likely incorrect, but I'm coming to java from a c/c++ background and don't know how to make the directories correctly for the given package. I'll look that up and see what I get. In the meantime, if you or anyone else could follow up with a link or a quick explanation on packages and directories that'd be great too.
    ~Sklave

  • Need help with in-line HTML code

    I am trying to write some in-line HTML code to change the background color to blue for Exception-Bad.  Here is my code
    I am trying to use in-line HTML code in WAD to change the background color for Exceptions-Bad to blue.  This is not working.  I really need to get this to work so if someone could tell what is wrong with my code, I would really appreciate the help.
                <style type="text/css" > SAPBEXexcBad7 {background-color: blue}; .SAPBEXexcBad8 {background-color: blue}; SAPBEXexcBad9 {background-color: blue} </style>
    Thanks.
    Ryan

    Hi Boater,
    HTML code will also come like this also
    BODY BACKGROUND="image.jpg" BGCOLOR="#FFFFFF" TEXT="#000000"
    let this one also
    Regards
    Ashwin

  • Friends need help desperate-- Second page not printing from the beginning

    Hi Friends,
    I have a large layout whose main-section is 8.5x20 (Width&height) which has 2 frames each having 2 repeating frames and about 20 fields in each repeating frame. When I run the report it shows the report right, but when I print, it prints only the first half since the report is long. When I change the property of the second frame of 'Page break before' to 'yes' it prints the second frame on the second page but print it at the same position as it printed on the first, and top of second page is all blank. How do I make to print from the beginning of the second page. Need your help.
    Thanks
    Joe.

    Hello,
    Most of the times, these problem are solved by "enclosing" the "Repeating frames" in frames with "Vertical Eleasticity" set to "Variable"
    Regards

  • Exit codes from the Java Virtual machine

    Hi,
    I've been asked to write a C wrapper program on UNIX and Windows which launches java (or java.exe) with the appropriate command line options and jar files to run an application.
    So far so good.
    However, I can't find any documentation saying how the status code returned by java or java.exe is constituted. e.g. How do you tell an error returned by the virtual machine, such as NoClassDefFoundError due to a missing jar or entry point, from a status code returned by a running Java application?
    Are the possible status codes returned by the JVM documented anywhere? Are they the same on UNIX and Windows? Should the Java application use a particular range of return status codes so they don't collide with the JVM's own?
    Thanks in advance for any pointers on the subject.

    Ah, I see, you're asking what if any existing codes are returned by the JVM implementation.Yep, that's it. I need to know that if the application chooses to use System.Exit to return (say) status code 2 meaning "your print job is queued", that the JVM won't ever return 2 meaning "couldn't find your application jar files" or some other generic condition outside the application's control.
    I can move the application's return codes into a specific value range, as long as I can find one that is guaranteed safe for JVMs on both UNIX and Windows. Sounds like that's a bit optimistic. Thanks for the source code suggestion, but don't really have control over the customers' choice of JVM.

  • Time Capsule:  Need help accessing my video surveillance DVR from the Internet.

    I am using the latest 4th Generation Time Capsule attached to a DSL Modem.  My 4 video Survilance DVR is connected to a switch then to the Time Capsule.  How or what is needed to be able to access the DVR via the internet.  I am able to access the DVR from within the home network only.  Would appreciate some guidance.
    Thanks in advance.

    Is the modem bridged?
    If not and working in router mode then the TC should be bridged.. this will never work if you have double NAT.
    Whichever box is the main router will need to forward the required ports for the camera dvr.. does the software use port 80 ie html?? That means you just forward port 80 to the IP address of the dvr. But find out the port.. the dvr instructions should tell you. Port forwarding on the TC.. ain't hard.. just google for the instructions. If the dsl modem is router, read its manual.
    You will need to lock the ip of the dvr so it doesn't shift. Do that in the router if possible but I am not sure you can on the TC. You will need to do it on the device using a static ip.
    The other thing is public IP .. do you have a static public address.. if not you will need to run dyndns. this is not available in the TC.. as most things are not available. So you will also need to check the dvr remote access instructions as it might have a dyndns client.. or you will have to use dsl modem as router even if you currently bridge it.
    Sorry this is making it complicated.
    Give some feedback and we can go from there.
    What is the main router?
    What modem is it exactly?
    What make and model is the DVR? A URL to the pdf manual will help if it gets complicated.
    What port do you use to access the DVR?
    Is there a dyndns client in the dvr?

  • Help on accessing tables of SAP from the Java Application

    Hi All
    I want to access some tables available in SAP through my Java program.  Do I have to write any code for database connectivity or straightaway I can write SQL statements in my Java code?
    Can anyone please suggest the sample code for this?
    Thanks in Advance,
    Vijay.

    the above one is with out connection pool, check this with connection pool.
    import com.sap.mw.jco.*;
    public class JcoTest {
    private static JCO.Client theConnection;
    private static IRepository theRepository;
        private static final String POOL_NAME = "myPool";
    public static void main(String[] args) {
        JCO.Pool connPool = JCO.getClientPoolManager().getPool(POOL_NAME);
        if (connPool == null) {
          JCO.addClientPool(POOL_NAME,
                            5,      //number of connections in the pool
                            "client",
                            "username",
                            "paswword",
                            "EN",
                            "hostname",
                            "00");
            theConnection = JCO.getClient(POOL_NAME);
      retrieveRepository(); 
      try {
      JCO.Function function = getFunction("RFC_READ_TABLE");
      JCO.ParameterList listParams = function.getImportParameterList();
      listParams.setValue("BSAUTHORS", "QUERY_TABLE");
      theConnection.execute(function);
      JCO.Table tableList = function.getTableParameterList().getTable("DATA");
      if (tableList.getNumRows() > 0) {
       do {
        for (JCO.FieldIterator fI = tableList.fields();
          fI.hasMoreElements();)
          JCO.Field tabField = fI.nextField();
          System.out.println(tabField.getName()
               + ":t" +
               tabField.getString());
         System.out.println("n");
       while (tableList.nextRow() == true);
      catch (Exception ex) {
       ex.printStackTrace();
      JCO.releaseClient(theConnection);
    private static void retrieveRepository() {
      try {
       theRepository = new JCO.Repository("saprep", theConnection);
      catch (Exception ex)
       System.out.println("failed to retrieve repository");
      public static JCO.Function getFunction(String name) {
        try {
             return theRepository.getFunctionTemplate(name.toUpperCase()).getFunction();
        catch (Exception ex) {
         ex.printStackTrace();
          return null;
    Regards
    vijay

  • Extracting specific detial about class from the JAVA API created by Javadoc

    hi ,
    Bacialy I need to get detials of all classes from the Java packages for my project. So i thought getting detials from the Java API document might be one way of doing it. If any one tell me some package or software which can get particulat text from the API document that will be great.
    Thank you,
    Raj

    Hi,
    I think, much easier way would be to write a little doclet. That doclet would take the information you need directly from the Doclet API and generate by it a plain text with the content you wish (for instance, as an SQL script that loads everything into a certain database).
    Obtaining this from the generated HTML documentation just adds one extra step (and a lot more complicated, by the way).
    Also, you can avoid even writing a doclet.
    There is a tool called DocFlex/Javadoc:
    http://www.filigris.com/products/docflex_javadoc/
    It is a template-driven doclet, which can be easily programmed to do the job. (However, a license will be needed).
    Regards,
    Leonid Rudy
    http://www.docflex.com

  • My i tunes account keeps telling me to enter valid security code from the back of my CC. i do and it keeps saying to enter it. i tried like 3 differnt cards. pls help cause i need apps for my new ipad3. thx

    hello, my itunes account keeps telling me to enter  a valid security code from the back of my CC. i do and it keeps saying to enter a valid one. i tried 3 differnt cards???? pls helppppp

    Usually there is some subtle difference other than the security code. E.g. your bank/credit card company says you live on Easy Street but you wrote Easy St. Compare your bank/credit card statement with the information you are trying to give Apple. If they don't match, for any reason, validation will fail with the same error message. No point giving the potential ID thief clues is there?
    tt2

  • I need help understanding how the Apple components integrate to create a system across all my devices?

    I need help understanding how the Apple components connect to create a whole system across all my devices?
    Is there a resource that describes current system and associated functionality?
    For example:
    Buy A, B, C to achieve "X" 
    You will need:
    an internet provider which supports <specs>
    add D to achieve "Y"
    You will need:
    an internet provider which supports <specs>
    add "E" to achieve "Z"
    You will need:
    an internet provider which supports <specs>
    For example, I am looking at the Gen 6 Airport extreme.  For intended performance do I need broadband? if so what are the specs, or will basic internet service suffice?  Do I need the internet provider's modem or does the Airport extreme replace that?  And then I think, if I am doing this, I should also look at Apple TV....What do I need and Why?  Then I look at the New Desk top coming out in the fall, and I think well, if I wait and get this, what does this component do for the system, and what becomes redundant? What does this awesome desktop do for my ability to sit and use a new macbook air when I travel  or sit on the couch in my PJs?
    If there was a place that plainly stated "if you buy the new dektop you can configure a system including only these components and achieve <this result> and by adding <additional components> you will achieve this result.
    I have been to the genius store a few times, but I come out of there more confused unless I have SPECIFIC questions or already know what to buy. 
    A "System Configuration App" would be a really great sales tool--Just saying.

    I have no idea what "fully optimized" means.
    No Apple device will let you watch broadcast TV. The Apple TV is a good option for watching streaming TV from iTunes, NetFlix and Hulu. If you want to watch from other sources, you may need to look at other devices.
    Any Mac computer or iPad will allow you to surf the web.
    What business software?
    Time Capsule is a good option for back ups.
    Update what across all devices?
    For accessing documents from all devices, a service like Dropbox is your best bet.
    I have no idea what "step as far away from an internet provider as possible" means. If you want Internet access, you need an Internet provider.
    Lighting fast speed for what? Processor? The specs are listed for all devices in the Online Store. Internet? We're back to the service provider.
    Technology changes. The only way to keep pace with it beyond a couple of years is to buy new stuff.
    The bottom line is you need to look at the specs for devices availble and at your budget and decide what best meets your needs. If you are unable to do that on your own, there are lot of technology consultants out there who will, for a fee, look at your exact situation, make recommendations and even handle the purchase and set up. Perhaps that would be the best route for you.
    Best of luck.

  • Need help understanding an example in Flex 4 Language Reference: flash.data.sqlstatement

    I don't understand how to use the example in Flash Builder. I read the link concerning this, but it's still unclear.
    1) Is this example a single file, or should the class definition be separate? I ask because I don't see any import statements at all, which makes me wonder how it would work.
    2) does init() act as the automatic entry point for this code, or is this function called from some unseen event?
    3) does dbStatement.itemClass = Employee represent the link between the main app and the class file?
    I've been looking all over for a solution to my problem in that I have 8 or 10 querries to a sqlite db in my main application and I would really like to move each to their own file, but I don't understand how to reference them from the main app, or how to share the results with the main app. I was hoping this was what I'm looking for.
    // Employee class definition
    package
        public class Employee
            public var name:String;
            public var ssn:String;
            public var id:uint;
            public override function toString():String
                return "id: "+ id.toString() + " name: " + name + " ssn: " + ssn;
    // using the Employee class as SQLStatement.itemClass
    var conn:SQLConnection;
    var dbStatement:SQLStatement;
    function init():void
        conn = new SQLConnection();
        conn.addEventListener(SQLEvent.OPEN, connOpenHandler);
        dbStatement = new SQLStatement();
        dbStatement.sqlConnection = conn;
        dbStatement.text = "SELECT id, name, ssn FROM employees";
        dbStatement.itemClass = Employee;
        var dbFile:File = new File(File.separator + "employee.db");
        conn.open(dbFile);
    function connOpenHandler(event:SQLEvent):void
        dbStatement.addEventListener(SQLEvent.RESULT, resultHandler);
        dbStatement.execute();
    function resultHandler(event:SQLEvent):void
        var result:SQLResult = dbStatement.getResult();
        if (result != null)
            var emp:Employee;
            var numRows:int = result.data.length;
            for (var i:int = 0; i < numRows; i++)
                emp = result.data[i];
                trace(emp.toString());
    Thanks
    Kristin

    Hi Kristin,
    1020: Method marked override must override another method.
    -overridesObject.toString
    There is popular misconception among ActionScripters about toString() method - if one want to provide custom implementation method of super class "override" keyword is needed.
    But in case of Object "toString" is dynamic and it is attached at runtime negating the need of overriding - instead implementation is to be provided by developer so one is not created at runtime. So one needs to just write her own: toString():String method.
    Methods of the Object class are dynamically created on Object's prototype. To redefine this method in a subclass of Object, do not use the override keyword. For example, a subclass of Object implements function toString():String instead of using an override of the base class.
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Object.html#toString()
    hth,
    kind regards,
    Peter

  • Cannot change Tax Code from the referenced sales order line

    hi,
    Has anyone ever got this error when creating Sales Order(SO): "*cannot change Tax Code from the referenced sales order line*"?
    The error occur with order type Return.
    This SO is created by copying from another SO.
    Please help.
    Regards & thanks,
    eRie

    hi,
    Has anyone ever got this error when creating Sales Order(SO): "*cannot change Tax Code from the referenced sales order line*"?
    The error occur with order type Return.
    This SO is created by copying from another SO.
    Please help.
    Regards & thanks,
    eRie

  • I need help with controlling two .swf's from third.

    Hi, thanks for reading!
    I need help with controlling two .swf's from third.
    I have a problem where I need to use a corporate designed
    .swf in a digital signage solution, but have been told by the legal
    department that it can not be modified in any way, I also can't
    have the source file yada yada. I pulled the .swfs from their
    website and I decompiled them to see what I was up against.
    The main swf that I need to control is HCIC.swf and the
    problem is it starts w/ a preloader, which after loading stops on a
    frame that requires user input (button press) on a play button,
    before the movie will proceed and play through.
    What I have done so far is to create a container swf,
    HCIC_container.swf that will act as Target for the HCIC.swf, and
    allow me to send actionscript to the file I'm not allowed to
    modify.
    I managed to get that done with the help of someone on
    another forum. It was my hope that the following script would just
    start HCIC.swf at a frame past the preloader and play button, and
    just play through.
    var container:MovieClip = createEmptyMovieClip("container",
    getNextHighestDepth());
    var mcLoader:MovieClipLoader = new MovieClipLoader();
    mcLoader.addListener(this);
    mcLoader.loadClip("MCIC.swf", container);
    function onLoadInit(mc:MovieClip) {
    mc.gotoAndPlay(14);
    But unfortunately it didn't solve my problem. Because there
    is a media-controller.swf, that is being loaded by HCIC.swf that
    has the controls including the play button to start HCIC.swf.
    Here's a link to a .zip file with all 3 .swf files, and all 3
    .fla files.
    http://www.axiscc.com/temp/HCIC.zip
    What I need to do is automatically start the HCIC.swf file
    bypassing the pre-loader and play button without editing it or the
    media-controller.swf in anyway. So all the scripting needs to be
    done in HCIC_container.swf.
    I know this is confusing, and its difficult to explain, but
    if you look at the files it should make sense.
    ActionScripting is far from my strong point, so I'm
    definitely over my head here.
    Thanks for your help.

    Got my solution on another forum.
    http://www.actionscript.org/forums/showthread.php3?t=146827

  • NEED HELP! - Installing Camera raw presets from USB Stick

    NEED HELP! -installing Camera raw presets from USB Stick.
    I am attempting to install the Camera Raw Presets. 
    It says to put them into User Name/Library/Application Support/Adobe/CameraRaw/Settings... 
    When I get to CameraRaw the ONLY folders in there are CameraProfiles & Lens Profiles. 
    I have searched everywhere looking for a CameraRaw-Settings folder and cannot find one. 
    I have latest version of CameraRaw installed and still no settings folder. 
    I even attempted to find it by looking in camera raw where it has saved the custom settings I made as presets and it shows that they are saved but will not show me where. 
    I am using CS5 specifically Photoshop v12.0.4 and Bridge. I have Lightroom 4. I have iMac OS  10.7.3
    Do I need to reinstall Camera Raw and how do you do that?
    Will I then lose my presets that I made in CameraRaw?  
    Thanks for your help

    Here is a note from the ACR 7.1 beta release.  http://labs.adobe.com/technologies/cameraraw7-1/?tabID=details
    Perhaps this answers question.
    Frequently Asked Questions
    Why is it no longer required to place the plug-in file in the specified directory on my hard drive?
    The Camera Raw update process has grown to include lens profile and camera profile files which are easiest to install via a single installer process instead of updating several different directories manually.

  • Need help trying to transfer my information from one iphone to another

    need help trying to transfer my information from one iphone to another

    If you are restoring from an icloud backup you are going to have to erase a content and setting and while in the setup prompts you will get the option to restore from an icloud back...that's the only time you will get the option to restore from an icloud back and that's during setup

Maybe you are looking for