Class of an array

String abc[] = {};
System.out.println(abc.getClass());The above prints: class [Ljava.lang.String; [/b] Is there such a class ? / which part of JLS specifies that?

> class [Ljava.lang.String;  Is there such a class ?
No, there is no such class as  [Ljava.lang.String.
Obviously this is to signal you have an array of java.lang.String
Why the prefix is [L I can not guess, but if you want to test if a given object is an array, you may
[code]
String abc[] = {};
if (abc.getClass().isArray())
  System.out.println("It is an array");
else
  System.out.printn("How could this happen=");
[/code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • How to copy an array element in one class to an array in another class?

    Hi,
    I have a ClassRoom class that stores a list of Student objects in an array. How would I copy a Student object from the Student[] array in the ClassRoom class to an array in another class?
    Is it something like this:
    System.arraycopy(Students, 2, AnotherClass.Array, 0, 2);In an array do the items get copied over existing array elements or can the be added to the end? If so, how would I specify add copied object reference to the end of the array in the other class?

    drew22299 wrote:
    Hi,
    I have a ClassRoom class that stores a list of Student objects in an array. How would I copy a Student object from the Student[] array in the ClassRoom class to an array in another class?
    Is it something like this:
    System.arraycopy(Students, 2, AnotherClass.Array, 0, 2);In an array do the items get copied over existing array elements or can the be added to the end? If so, how would I specify add copied object reference to the end of the array in the other class?System.arrayCopy will overwrite whatever is already in the array. It is your job to make sure it copies into the proper array location.
    That being said, you're only moving a single student. This is not something you would use arrayCopy for, as you can just do that with simple assignment. Also, you should consider giving Class a method to add a student to its student list, as the class should know how many students it has and can easily "append" to the array.
    Note: I hope you noticed the quotes around append. Java's arrays are fixed size. Once allocated, their size cannot change. You may want to consider using one of the List implementations (ArrayList, for example) instead.

  • Getting the "code" of a class as byte array

    Hi!
    My problem is the following. My algorithm gets a Class object and it should return the code of the class as byte array.
    e.g. public byte [] getTheCode (Class forThisClass);
    I found out, that I can get an InputStream for a ressource, so that i can load my own classes like getResourceAsStream("my/package/MyClass.class"), but it should also be possible to get the code of the built-in classes like String, Integer etc.
    thanks, Ingo

    The real name of String is java.lang.String; perhaps you didn't use the full name.No, that's not the problem. The classloader of java.lang.String is usually the bootstrap class loader, and its Class.getClassLoader() == null.
    Class.getClassLoader() explicitly defers to the system class loader (not the bootstrap class loader) if getClassLoader() == null, The system class loader (the thing that looks at CLASSPATH, etc.) cannot load anything from rt.jar.
    So basically I think you're sort of SOL, unless you want to check for this condition yourself. I.e. first try your approach (using getResourceAsStream()), and if that returns null, go and open ${java.home}/lib/rt.jar, and walk it on your own.

  • Public class ArrayEx extends Array

    Hi, I'm very bad at OO programming, but I'm trying to learn.
    I want to add some functions to my Arrays, like checking if
    arrays contain a value (indexOf can be equal to 0, which is false,
    though actually I'm used to the loose data typing of as2, so this
    may not be quite true. Bear with me though, I want to learn how to
    extend a class). So I'm trying to write a class that extends the
    basic Array class.
    I am confused about the constructor, I want to mimic the
    behaviour of the Array class but I'm not sure if I need to write
    functions for each method of Array. Since my ArrayEx extends the
    Array class it should inherit the array functions right? So it
    should already have .pop() and .push() ext. defined? How should I
    write my constructor to store the data the same way as the Array
    class does though?
    Is there somewhere I can look at the internal Array class to
    figure out how it does it?
    What I have written so far appears at the bottom of the
    message. I include questions as comments.
    I hope someone can help me out. I'm sorry if I'm asking stuff
    that seems obvious. Thanks for your time.
    Jon

    I've found the solution to my second set of problems and
    since I chose to trouble you all with the question I thought I'd
    post the answer.
    First problem, I had declared the ArrayEx class as dynamic
    but not as public. Should read;
    dynamic public class ArrayEx extends Array{
    Second problem. An empty constructor function, by default,
    calls the parent constructor function with no arguements. Since I
    wanted to construct my new array class like the default array class
    i had to add some code to handle that.
    So here is the working class;

  • About Class Object  as Array

    Hello.. I'm beginner in Java Programming
    Now i learn about Array.. i'm not understand about use class object become array. for example i'm create class object Card.
    Then i call Card object to CardTest as main object and Card object called as array.
    can you tell me about how to work Card object as array in CardTest ?
    Edited by: 994075 on Mar 14, 2013 11:55 PM

    994075 wrote:
    yup..thanks guru :DI'm no guru, I just bought a decent Java book 10 years ago and here I am.
    so i guess Object Class can be array :).I don't get that statement. You can store objects in an array, if that's what you mean. An array itself is also an object.
    but i'm not understrand if static method in Card object can be called automatically when Card initialized in CardTest?a) research constructors
    b) you usually don't need static methods, its just something that people new to the language tend to overuse because then you don't have to create object instances. Forget about static methods, try to make it work using regular non-static methods.
    And you really should read and study more, you're coming to the forum way too soon. First get a solid knowledge base, the only thing you're doing now is asking questions that you could have answered for yourself by studying more.

  • Class Composition with Array's - New to Java

    Greetings.
    I have the basic foundtion to my program laid and it seems to be doing what i need it to. However in my transaction method I have an "If" statement that is supposed to process a transaction differently based on the type of member. Based on what I have done the program operates fine if I make member type static. I will include the areas of code that refer to the problem of the member type and the error i recieve. Hopefully it will be enough to demonstrate what I am doing wrong.
    Outline of the Problem
    Create an Array of Users (user) - Working
    Create and Array of Accounts containing Beginning balance and Account Number (accountNum) - Working
    Set Array owner using last name - Working
    Process Transactions - Returning the returning the following error:
    Exception in thread "main" java.lang.NullPointerException
         at account.transaction(account.java:90)
         at accountTest.main(accountTest.java:64)
    If i set memberType to static It worked earlier. I hope this is enough code and description to help identify the problem. I can include more if you need.
    Thank you in advance!
    Lava
    Class Customer
         private String firstName;
         private String lastName ;
         private String memberType;
         public customer(String first, String last, String member)
              firstName = first;
              lastName = last;
              memberType = member;
         public void setMemberType( String m )
               memberType = m;
         public String getMemberType()
              return memberType;
         }Class Account
         private customer owner;
    public void setOwner(customer user)
              owner = user;
         public customer getOwner()
              return owner;
    public void transaction(account[] accountNum)
    if ( owner.getMemberType().equals("Premier" ));

    >
    Based on what I have done the program operates fine if I make member type static. >
    It has to do with how static fields and instance fields are or are not given default values at runtime. Making the customer member static means that for all instances of the Account class, the customer variable will refer to the same object. For different objects of the Account class, will your customer variable refer to the same object? If so, it should be static and thus a class member. If not, it should be an instance member.

  • Which class is java array??

    for example, a 'name' array.
    To see its length, use the reference name, ---> name.length
    so I conclude that name's array class must have the static varriable length.
    but what is that class?? where is it in the API??

    Do you mean this class is only implemented byJVM??
    Yep.
    ie, an array type could have any name??I believe the JLS specifies what array class names
    will be.
    public class ArrayTypes {
    public static void main(String[] args) throws
    rows Exception {
    System.out.println(new
    ntln(new byte[0].getClass().getName());
    System.out.println(new
    ntln(new char[0].getClass().getName());
    System.out.println(new
    ntln(new short[0].getClass().getName());
    System.out.println(new
    ntln(new int[0].getClass().getName());
    System.out.println(new
    ntln(new long[0].getClass().getName());
    System.out.println(new
    ntln(new float[0].getClass().getName());
    System.out.println(new
    ntln(new double[0].getClass().getName());
    System.out.println(new
    ntln(new boolean[0].getClass().getName());
    System.out.println(new
    ntln(new Object[0].getClass().getName());
    System.out.println(new
    ntln(new ArrayTypes[0].getClass().getName());
    System.out.println(new
    ntln(new ArrayTypes[0][0].getClass().getName());
    System.out.println(new
    ntln(new int[0][0].getClass().getName());
    [B
    [C
    [S
    [I
    [J
    [F
    [D
    [Z
    [Ljava.lang.Object;
    [LArrayTypes;
    [[LArrayTypes;
    [[I
    Very cool experiment there jverd. That gets props from me.

  • Compile error on .class for an array.

    How do I write the code below correctly?
            final ArgumentCaptor<MessageToken[]> tokenArg = ArgumentCaptor.forClass(MessageToken[].class);

    How do I write the code below correctly?
    final ArgumentCaptor<MessageToken[]> tokenArg = ArgumentCaptor.forClass(MessageToken[].class);
    What is the exact compilation error?
    Note that since ArgumentCaptor is probably a custom class that only you or your team knows about, we will maybe not be able to help a lot, we will probably need that you give us the signature of its method forClass
    Note that the problem is not that the syntaxfor the array class MessageToken[].class is illegal in itself; the following compiles perfectly:
    public class TestClassLitteral {
        Class stringClass = String.class;
        Class stringArrayClass = String[].class;
    }

  • AppleScript Class recognition and Array count

    I have an application "SolarMaxOsX" written in Obj C
    This app is scriptable
    I have a class named Ups and in Ups.m I have written  following methods:
    - (id)init {
        self = [super init];
        NSLog(@"Init Ups at %p", self);
        self.upsName = [NSString stringWithFormat:@"S2000"];
    //    upsPort = [NSNumber numberWithInteger:1];
        self.upsPort = 1;
        self.upsIpAddress= [NSString stringWithFormat:@"192.168.10.101"];
        self.upsDataListToDisplayInTable = [self fillUpsListDictionary];
        _uniqueID = [[NSUUID UUID] UUIDString];
        return self;
    /* For appleScript recognition */
    - (BOOL)application: (NSApplication *)  sender delegateHandlesKey:(NSString *)key   {
        if ([key isEqualToString: @"Ups"]) return YES;
        if ([key isEqualToString: @"upsDescriptionDict"]) return YES;
        if ([key isEqualToString: @"networkStatus"]) return YES;
        if ([key isEqualToString: @"networkOk"]) return YES;
        return NO;
    - (NSUniqueIDSpecifier *)objectSpecifier {
        NSScriptClassDescription *appDescription = (NSScriptClassDescription *)[NSApp classDescription];
        return [[NSUniqueIDSpecifier alloc] initWithContainerClassDescription:appDescription containerSpecifier:nil key:@"Ups" uniqueID:self.uniqueID];
    In AppDelegate.m:
    There is an array : Upss declared as follows:
    NSArray (Upss *) Ups; declared and initialised in AppDelegate.m file
    self.Upss = [self initUpss];
    sdef file for SolarMax Suite follows (compiles correctly)
    <suite name="SolarMax Suite" code="SMap" description="Apple Events supportés par l&apos;application SolarMaxMain">
    <class name="Ups" code="SCup" description="An object UPS in SolarMaxOsX." >
    <cocoa class="Ups" inherits="item" plural="Upss"/>
    <property name="id" code="ID  " type="text" access="r" description="The unique identifier of the note.">
    <cocoa key="uniqueID"/>
    </property>
    </class>
    <element description="List of Ups" type="Ups">
    <cocoa key="Upss"/>
    </element>
    <class name="AppDelegate" code="SCad" description="main class in SolarMaxOsX.">
    <cocoa class="AppDelegate" />
    // Liste des Ups reconnus dans le fichier de configuration
    <property name="Upss" code="SMno" type="Ups" access="r">
    <cocoa key="Upss"/>
    </property>
    </class>
    </suite>
    I want to get a count for array Upss
    Script follows
    tell application "/Users/guydesbief/Library/Developer/Xcode/DerivedData/SolarMaxOsX-cgcuhyptmpmtiegixfnbbhpexjhn/Build/Products/Debug/SolarMaxOsX.app" to activate
    -- delay 30
    tell application "/Users/guydesbief/Library/Developer/Xcode/DerivedData/SolarMaxOsX-cgcuhyptmpmtiegixfnbbhpexjhn/Build/Products/Debug/SolarMaxOsX.app"
        --    set nomAppli to the name of application
        --    set theWindows to windows
        set NbWin to the count of windows
        set theWindow to first item of windows
        properties of the theWindow
        tell window "UPS Sumary"
            --click on "Statistics button"
            -- click  on button 1 of theWindow
            --        set enabled of button1 to true
        end tell
        --class of Upss
        count of Upss
    end tell
    I get the following answers:
    tell application "SolarMaxOsX"
        activate
        count every window of current application
            --> 1
        get item 1 of every window
            --> window id 3113
        get properties of window id 3113
            --> {closeable:true, zoomed:false, class:window, index:1, visible:true, name:"UPS Sumary", miniaturizable:true, id:3113, miniaturized:false, resizable:true, bounds:{1485, 31, 1985, 579}, zoomable:true}
        count every Ups of current application
            --> error number -1728
    Résultat :
    error "Erreur dans SolarMaxOsX : Il est impossible d’obtenir every Ups." number -1728 from every Ups
    What do I have missed ?
    Logiciel  OS X 10.9.5 (13F34) (Mavericks)
    Xcode Version 6.1 (6A1052d)
    Éditeur AppleScript Version 2.6.1 (152.1)
    AppleScript 2.3.2

    Hi Hiroto
    It is much better thanks
    Now count of onduleurs works
    Hi Hiro,
    It is much better Thanks for your help
    Now, count od onduleurs works
    tell application "/Users/guydesbief/Library/Developer/Xcode/DerivedData/SolarMaxOsX-cgcuhyptmpmt iegixfnbbhpexjhn/Build/Products/Debug/SolarMaxOsX.app" to activate
    -- delay 30
    tell application "/Users/guydesbief/Library/Developer/Xcode/DerivedData/SolarMaxOsX-cgcuhyptmpmt iegixfnbbhpexjhn/Build/Products/Debug/SolarMaxOsX.app"
           --    set nomAppli to the name of application
           --    set theWindows to windows
           class of onduleurs
           count of onduleurs
           --    get properties
           set NbWin to the count of windows
           set theWindow to first item of windows
           properties of the theWindow
           tell window "UPS Sumary"
                 --click on "Statistics button"
                 -- click  on button 1 of theWindow
                 --           set enabled of button1 to true
           end tell
           get properties
           get id of first onduleur of onduleurs
    The results in appleScript:
    tell application "SolarMaxOsX"
             activate
             get class of every onduleur
                     --> {onduleur, onduleur, onduleur}
             count every onduleur of current application
                     --> 3
             count every window of current application
                     --> 1
             get item 1 of every window
                     --> window id 9796
             get properties of window id 9796
                     --> {closeable:true, zoomed:false, class:window, index:1, visible:true, name:"UPS Sumary", miniaturizable:true, id:9796, miniaturized:false, resizable:true, bounds:{30, 28, 530, 576}, zoomable:true}
             get properties
                     --> error number -10000
    Résultat :
    error "Erreur dans SolarMaxOsX : Le gestionnaire AppleEvent a échoué." number -10000
    And the results of my logging in Objective C debugger:
    My sdef file
    2014-12-01 23:56:36.040 SolarMaxOsX[37551:303] Appdelegate handles onduleursArray
    2014-12-01 23:56:36.040 SolarMaxOsX[37551:303] handles onduleursArray OK
    2014-12-01 23:56:36.041 SolarMaxOsX[37551:303] Appdelegate handles onduleursArray
    2014-12-01 23:56:36.041 SolarMaxOsX[37551:303] handles onduleursArray OK
    2014-12-01 23:56:36.042 SolarMaxOsX[37551:303] Appdelegate handles orderedWindows
    2014-12-01 23:56:36.042 SolarMaxOsX[37551:303] Appdelegate handles orderedWindows
    2014-12-01 23:56:36.043 SolarMaxOsX[37551:303] Appdelegate handles orderedWindows
    2014-12-01 23:56:36.043 SolarMaxOsX[37551:303] Appdelegate handles orderedWindows
    2014-12-01 23:56:36.044 SolarMaxOsX[37551:303] Appdelegate handles scriptingProperties
    2014-12-01 23:56:36.044 SolarMaxOsX[37551:303] Appdelegate handles classCode
    2014-12-01 23:56:36.044 SolarMaxOsX[37551:303] Appdelegate handles onduleursArray
    2014-12-01 23:56:36.045 SolarMaxOsX[37551:303] handles onduleursArray OK
    2014-12-01 23:56:36.045 SolarMaxOsX[37551:303] Appdelegate handles terminologyVersion
    2014-12-01 23:56:36.045 SolarMaxOsX[37551:303] Appdelegate handles version
    2014-12-01 23:56:36.045 SolarMaxOsX[37551:303] Appdelegate handles name
    2014-12-01 23:56:36.045 SolarMaxOsX[37551:303] Appdelegate handles isActive
    2014-12-01 23:56:36.046 SolarMaxOsX[37551:303] An exception was thrown during execution of an NSScriptCommand...
    2014-12-01 23:56:36.046 SolarMaxOsX[37551:303] Error while returning the result of a script command: the result object...
    classCode = 1667330160;
    isActive = 1;
    name = SolarMaxOsX;
    onduleursArray =     (
    "<Ups: 0x6000002c0bd0>",
    "<Ups: 0x6100002c24c0>",
    "<Ups: 0x6000000df100>"
    terminologyVersion = 1;
    version = "1.1";
    ...could not be converted to an Apple event descriptor of type 'application properties'. The 'onduleursArray' entry could not be converted to an Apple event descriptor of type 'onduleur'. This instance of the class '__NSArrayM' returned nil when sent -objectSpecifier (is it not overridden?) and there is no coercible type declared for the scripting class 'onduleur'.
    It seems that my objectSpecifier method in Ups Category (or Ups class) is never called
    My sdef File:
        <!-- Suite Solar Max -->
        <suite name="SolarMax Suite" code="SMap" description="Apple Events supportés par SolarMaxOsX">
            <!-- suppress warning for missing "savable file format" type -->
            <enumeration name="savable file format" code = "savf" hidden="yes">
                <enumerator name= "dummy" code="VTdm"
                description="A dummy file format."/>
            </enumeration>
            <class name="application" code="capp" description="SolarMaxOsX’s top level scripting object." plural="applications" inherits="application">
                <cocoa class="NSApplication"/>
    <element type="onduleur" access="r">
                        <cocoa key="onduleursArray"/>
                </element>
                <property name="onduleurs" code="SMor" description="Array of onduleurs." access="r">
                    <type  type="onduleur" list="yes"/>
                <cocoa key="onduleursArray"/>
                </property>
                <property name="name" code="pnam" description="The name of the application." type="text" access="r"/>
                <property name="frontmost" code="pisf" description="Is this the frontmost (active) application?" type="boolean" access="r">
                    <cocoa key="isActive"/>
                </property>
                <property name="version" code="vers" description="The version of the application." type="text" access="r"/>
                <property name="terminology version" code="TEvn" type="integer" access="r">
                    <cocoa key="terminologyVersion"/>
                </property>
            </class>
    <class name="onduleur" code="SCup" description="An object onduleur in SolarMaxOsX." plural="onduleurs">
                <cocoa class="Ups" inherits="item" />
                <property name="id" code="ID  " type="text" access="r" description="The unique identifier of the onduleur">
                    <cocoa key="uniqueID"/>
                </property>
                <property name="OnduleurName" code="pnam" description="The onduleur name. ." type="text">
                    <cocoa key="name"/>
                </property>
           </class>
            // Class SolarMaxOsX to access to first window
            <class name="SolarMaxOsX" code="SMos" description="main window in SolarMaxOsX.">
            <cocoa class="SolarMaxOsX" />
    </class>
        </suite>
    Categories for all classes in he same file: AppDelegate+AppleScriptExtensions.m (category file)
    //  SolarMaxOsX+AppleScriptExtensions.m
    //  SolarMaxOsX
    //  Created by  Guy DESBIEF on 28/11/2014.
    #import "AppDelegate+AppleScriptExtensions.h"
    #import "Ups.h"
    @implementation NSObject (MNscriptability)
    - (void) returnError:(int)n string:(NSString*)s {
        NSScriptCommand* c = [NSScriptCommand currentCommand];
        [c setScriptErrorNumber:n];
        if (s)
            [c setScriptErrorString:s];
    @end
    @implementation AppDelegate (AppleScriptExtensions)
    #define APPLESCRIPT_TERMINOLOGY_VERSION 1
    #pragma mark ACCESSOR METHODS
    -(NSNumber *) terminologyVersion {
        return [NSNumber numberWithInt:APPLESCRIPT_TERMINOLOGY_VERSION];
    // For appleScript recognition
    -(NSUInteger) countOfOnduleursArray
        MyLog(@"countOfOnduleursArray");
        return [self.onduleursArray count];
    - (Ups *) objectInOnduleursArrayAtIndex : (int) index {
        MyLog(@"objectInOnduleursArrayAtIndex %index", index);
         Ups *upsItem = [self.onduleursArray objectAtIndex:index];
        if (upsItem != nil)
            return upsItem;
        } return nil;
    - (Ups *) valueInOnduleursArrayAtIndex:(unsigned int)i {
        MyLog(@"valueInOnduleursArrayAtIndex %i", i);
        if (![[NSScriptCommand currentCommand] isKindOfClass:[NSExistsCommand class]])
            if (i >= [onduleursArray count]) {
                [self returnError:errAENoSuchObject string:@"No such Ups."];
                return nil;
        MyLog(@"valueInOnduleursArrayAtIndex index OK: %i", i);
        return [onduleursArray objectAtIndex: i];
    - (BOOL)application: (NSApplication *)  sender delegateHandlesKey:(NSString *)key   {
         MyLog(@"Appdelegate handles %@",key);
        if ([key isEqualToString: @"terminologyVersion"]) return YES;
         if ([key isEqualToString: @"onduleursArray"]) {
           MyLog(@"handles %@ OK",key);
         return YES;
        return NO;
    @end
    @implementation Ups (AppleScriptExtensions)
    - (NSUniqueIDSpecifier *) objectSpecifier
        MyLog(@"objectSpecifier (UPS) OK");
        return [[NSUniqueIDSpecifier allocWithZone:[self  zone]]
                initWithContainerClassDescription: (NSScriptClassDescription *)[NSApp classDescription]
                containerSpecifier: nil
                key: @"onduleursArray"
                uniqueID: uniqueID];
    @end
    AppDelegate+AppleScriptExtensions.h (category file)
    // SolarMaxOsX+AppleScriptExtensions.h
    //  SolarMaxOsX
    //  Created by  Guy DESBIEF on 28/11/2014.
    #import <Foundation/Foundation.h>
    #import "AppDelegate.h"
    @class AppDelegate;
    @class Ups;
    @interface NSObject (MNscriptability)
    - (void) returnError:(int)n string:(NSString*)s;
    @end
    @interface AppDelegate  (AppleScriptExtensions)
    #ifdef NDEBUG
    #define MyLog(f, ...)
    #else
    #define MyLog(f, ...) NSLog(f, ## __VA_ARGS__)
    #endif
    - (BOOL)application: (NSApplication *)  sender delegateHandlesKey:(NSString *)key;
    - (NSUInteger) countOfOnduleursArray;

  • Unable to load Java classes from byte arrays.

    I have an application started through JWS. It works fine except for one problem. The application allows the user to load an external class, typically received over a socket. These are not (and cannot) be signed. My application complains about not being able to load these when starting through JWS. When starting the application locally (i.e., run the jar file using 'java -jar APP.jar') it works fine.
    I guess I have to grant som additional permissions in my policy-file. But since these classes are user-defined, there is no way for me to define a static codebase. `
    Any ideas?

    Java Web Start installs a SecurityManager, and after that is responsible for assigning permission collections to any code loaded by the JNLPCLassLoader.
    If you have all-permissions for your jnlp loaded code, then use another ClassLoader to load some other code, That other class loader will assign the permissions to that code. If that ClassLoader dosn't extend SecureClassLoader, the code will get only the default permissions.
    You can fix this by
    1.) Use a ClassLoader that extends SecureClassLoader, and override getPermissions(), or
    2.) just call System.setSecurityManager(null), from the trusted code loaded by the JNLPCLassLoader.
    /Dietz

  • How to create an instance of a class which is actually an array?

    the following code gives a runtime exception
    Object obj = (Object )attributeClass.newInstance();
    Exception:
    java.lang.InstantiationException: [Ltest.Name;[/b]
    Here test.Name is user defined class and i want to create an array instance of that class.
    I have tried the following also:
    [b]Object methodArgs[] = new Object[length];
    for(int j=0;j<length;++j){
    methodArgs[j] = singleMemberClass.cast(testArray[j]);
    Object temp = attributeClass.cast(methodArgs);
    In the above code singleMemberClass is test.Name, but the last line gives the following exception.
    java.lang.ClassCastException
    Message was edited by:
    lalit_mangal
    Message was edited by:
    lalit_mangal

    Try the following code
    import java.lang.reflect.Array;
    public class TestReflection {
         public static void main(String args[]) {
              Object array = Array.newInstance(A.class, 3);
              printType(array);
         private static void printType(Object object) {
              Class type = object.getClass();
              if (type.isArray()) {
                   System.out.println("Array of: " + elementType);
              System.out.println("Array size: " + Array.getLength(object));
    class A{
    }

  • The object array comes under which class

    hi there,
    can anybody tell me an array is defined in which class .
    for ex: when we give
    int a[ ]=new int[ ]
    wen "new "is used an object of array is created.
    and i studied somewhere that array is an object.
    then wen an array is an object it must b defined in a class.
    can anybody tell me in wich class.
    its urgent..
    plz do it as fast as possible
    take care'
    bye

    Actually I think the question was what class is the
    array ie arr.getClass().getName().Ah, I see. I guess I misread the question.
    I believe that the jvm creates them at runtime as
    necessary. Seeing as there are infinite
    possibilities for array types, it couldn't happen any
    other way.The class must also be available at compile time, not? Or else the compiler just "pretends" there's such a class, because it knows the rules of the language.

  • Extending Array class, get Error #1069: Property 0 not found with indexOf call

    I'm using inheritance to extend the Array class to create a Paths class that moves Sprites/MovieClips around on the screen. I'm getting an odd error on a call to indexOf. Here's the error:
    ReferenceError: Error #1069: Property 0 not found on Paths and there is no default value.
        at Array$/_indexOf()
        at Array/http://adobe.com/AS3/2006/builtin::indexOf()
        at Paths/Next()[D:\Stephen\Documents\Flash\TossGame\TossGameFirstPerson\Paths.as:40]
    Here's the relevant code in the Paths class:
        public class Paths extends Array
            private var cCurrentPath:Path;
            public function Next():Path
                var lArray:Array = this;
                var lNextIndex:int = indexOf(cCurrentPath) + 1;
                if (lNextIndex == length) lNextIndex = 0;
                var lPath:Path = lArray[lNextIndex];
                return lPath;
        } // class
    I get the error at the highlighted line. cCurrentPath is populated with a Path object which is the object located at position 0 of the this object (Paths). I've tried the following variants of the Next() function:
    public function Next():Path
         var lArray:Array = this;
          var lNextIndex:int = lArray.indexOf(cCurrentPath) + 1;
          if (lNextIndex == lArray.length) lNextIndex = 0;
          var lPath:Path = lArray[lNextIndex];
          return lPath;
    public function Next():Path
         var lArray:Array = this;
          var lNextIndex:int = this.indexOf(cCurrentPath) + 1;
          if (lNextIndex == this.length) lNextIndex = 0;
          var lPath:Path = lArray[lNextIndex];
          return lPath;
    public function Next():Path
         var lArray:Array = this;
          var lNextIndex:int = super.indexOf(cCurrentPath) + 1;
          if (lNextIndex == super.length) lNextIndex = 0;
          var lPath:Path = lArray[lNextIndex];
          return lPath;
    Same error happens whichever I try. Anyone got any ideas?
    Stephen
    Flash Pro CS3 (Version 9.0)

    Mark your class dynamic.
    public dynamic class Paths extends Array

  • Working with Classes and Arrays

    hello to all,
    public class Store
    //private data
    private Person list[];
    private int count;
    private int maxSize;
    //constructor starts
    public Store(int max)
    count = Person.count(); //sets count to 0     
    maxSize = max;//maxSize is equals to max
    Person list[] = new Person[maxSize];
    }//end of store
    //constructor ends
    //accessor starts   
    public int getCount()
    for(int i=0; i<list.length; i++)
    int result = list;
    return result;
    }//returns the number of elements currently in store
    the code above is working with classes and some arrays
    what am trying to do is to display what the array holds
    and then i meet an error saying that
    INCOPATIBLE TYPES - FOUND PERSON BUT EXPECTED INT
    Please note that am new to this!
    Thank you in advanced!
    <img src="file:///C:/Documents%20and%20Settings/fh84/Desktop/untitled.JPG" alt="" />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    public class Store
        //private data
        private Person list[];
        private int count;
        private int maxSize;
    //constructor starts
        public Store(int max)
             count = Person.count(); //sets count to 0     
             maxSize = max;//maxSize is equals to max
            // Person list[] = new Person[maxSize];
             Person list[] = new Person[maxSize]; //set tne
        }//end of store
    //constructor ends
    //accessor starts  
        public int getCount()
            for(int i=0; i<list.length; i++)
                int  result = list;
    return result;
    am sending the code again                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • HELP PLZ!! Array Button Menu that fades in/out content with Tweener or Tween Class...!!!

    OK.
    So I've been trying the last couple of days to make 2 different codes i had into one...
    The first on is using the Tweener class and everytime that I press a button it fades out the loaded content of the previous selection, waits for it to finish and then loads the content of the button pressed. Everything works fine with this part.
    The second code is the on that is using an Array to dynamicaly rollover, rollout and keep selected the buttons.
    It was also changing the content of the mc that everything is loaded on but without this fancy fade in - fade out...!!
    So i think its time for some code now...:
    Here are 2 different approaches:
    This is the code that uses the onMotionFinished of the Tween Class:
    var groupinfo:Array = [ {mc:about, toload:"mcHome"},
         {mc:service, toload:"mcService"},
         {mc:contact, toload:"mcContact"}];
    var activebtn:MovieClip;
    var holder1:MovieClip = _root.attachMovie("mcHome", "mcMain", 10);
    holder1._x = 0;
    holder1._y = 110;
    function doClick() {
    //          \/THE PROBLEM IS FROM HERE\/
         if (this != activebtn){
              var mcTween:Tween = new Tween(mcMain, "_alpha", Strong.easeOut, 100, 0, 1, true);
              mcTween.onMotionFinished = function() {
                   _root.holder1.attachMovie(this.p, "mcMain", 1);
                   var mcTween2:Tween = new Tween(mcMain, "_alpha", Strong.easeOut, 0, 100, 10, true);
    //          /\UNTIL HERE/\
         var prevbtn:MovieClip = activebtn;
         activebtn = this;
         this.gotoAndStop(FADEINSTOP);
         prevbtn.onRollOut();
    function init() {
       for (var element in groupinfo) { 
          // btn is a pointer to one of the nav buttons
          var btn:MovieClip = groupinfo[element].mc;      
          // have each button remember which library/mc it is supposed to load
          btn.p = groupinfo[element].toload;      
          // assign functions to each event
          btn.onRollOver = doRollOver;
          btn.onRollOut = doRollOut;
          btn.onRelease = doClick;
    init();
    And the Example:
    The onMotionTween code works ok with the tweening but doesn't change the movieclip.
    This is the code that uses the caurina Tweener Class with no onMotionFinished:
    var groupinfo:Array = [{mc:about, toload:"mcHome"},
                                {mc:service, toload:"mcService"},
                                {mc:contact, toload:"mcContact"}];
    var activebtn:MovieClip;
    var holder1:MovieClip = _root.attachMovie("mcHome", "mcMain", 10);
    holder1._x = 0;
    holder1._y = 110;
    function doClick() {
    //          \/PROBLEM FROM HERE\/
         if (this != activebtn) {
              Tweener.addTween(mcMain,{_alpha:0, time:1, transition:"easeOutQuart"});
              var holder2:MovieClip = _root.attachMovie(this.p, "mcMain2", 11);
              holder2._alpha = 0;
              holder2._x = 0;
              holder2._y = 110;
              Tweener.addTween(mcMain2,{_alpha:100, time:1, delay:1, transition:"easeOutQuart"});         
              mcMain = mcMain2;
    //           /\TO HERE!!!/\
         var prevbtn:MovieClip = activebtn;
         activebtn = this;
         this.gotoAndStop(FADEINSTOP);
         prevbtn.onRollOut();
    function init() {
         for (var element in groupinfo) {
              // btn is a pointer to one of the nav buttons
              var btn:MovieClip = groupinfo[element].mc;
              // have each button remember which library/mc it is supposed to load
              btn.p = groupinfo[element].toload;
              // assign functions to each event
              btn.onRollOver = doRollOver;
              btn.onRollOut = doRollOut;
              btn.onRelease = doClick;
    init();
    Other Example:
    The Tweener code works perfectly this first time but the second time removes the conent and does just the fade in.
    The code for the buton group i got it from                     here...
    Please could someone help me with this thing!!
    I think its a great piece of dynamic code if we can eventualy make it  work properly!!
    Thanksss!!!
    Shorten the code...  Left only the part that needs mod!!

    clbeech, Thank you but doesnt do anything either....!!It is a  bit usefull but... !!
    The problem is that the code cant give the "this.p" to the movieclip...
    Here is the mess i've made with few changes from your part... and alot of treces to wich detected that the this.p is can't get in the onMotionFinished function...
    its only the doClick function:
    function doClick() {
         trace ("---------vars after click----------")
         trace ("activebtnStart  "+  activebtn);
         trace ("this.p  OutPre:  " + this.p);
         if (this != activebtn){
              trace ("mcMainAlphaBefore:  " + mcMain._alpha);
              trace ("mcMainBefore:  " + mcMain);
              var mcTween:Tween = new Tween(mcMain, "_alpha", Strong.easeOut, 100, 0, 1, true);
              mcTween.onMotionFinished = function() {
                   holder["mcMain"].removeMovieClip();
    //               trace ("mcMainStart:  " + mcMain);
    //               trace ("mcMain2Start:  " + mcMain2);
    //               trace ("mcMainAlphaStart:  " + mcMain._alpha);
    //               trace ("mcMain2AlphaStart:  " + mcMain2._alpha);
                   trace ("this:  " + this);
                   trace ("this.p  Pre:  " + this.p);
                   holder.attachMovie(btn.p, "mcMain", 1);
                   holder.alpha = 0;
                   trace ("this.p  After:  " + this.p);
    //               mcMain = mcMain2;
                   new Tween(mcMain, "_alpha", Strong.easeOut, 0, 100, 10, true);
    //               mcMain._alpha = 100;
    //               trace ("mcMainEnd:  " + mcMain);
    //               trace ("mcMain2End:  " + mcMain2);
    //               trace ("mcMainAlphaEnd:  " + mcMain._alpha);
    //               trace ("mcMain2AlphaStart:  " + mcMain2._alpha);
         trace ("this.p  OutAfter:  " + this.p);
         var prevbtn:MovieClip = activebtn;
         activebtn = this;
         this.gotoAndStop(FADEINSTOP);
         prevbtn.onRollOut();
         trace ("this.p  "+  this.p);
         trace ("this  "+  this);
         trace ("prevbtn  "+  prevbtn);
         trace ("activebtn  "+  activebtn);    
    Pfff.....
    I think its best to Attach the .fla!!
    Please have a look on it if you have anytime..!!
    Thanks for your interest..

Maybe you are looking for

  • Express XY plot - Overplot timeline

    I tried to plot a graph using the XY Express. The X axis is a timeline. The problem starts to occur after 5 minutes. The X axis (timeline) doesn't move itself, but for instance, there is no problem if the timeline axis moves. The past is not too impo

  • Weblogic Cluster and Perfoemance Reduction

              Hi All,           Is there a performance reduction caused by using Weblogic Clustering?           I am experiencing much slower performance in my clustered           environment compared to my non-clustered environment. They           are b

  • Exception "algorithm ARC4 is not available from Provider Cryptix "

    hi all i am developing the application in which i am using two encryption/decryption algorithms one is "RC4" and second is "AES(256 bit key)". 1.first i am taking the credit card number from database which is in the encrypted format using 'RC4". 2.Af

  • Reprocess BPM's

    Hi everyone: I wanna reprocess workflows in XI(BPM) when they have failed. I wanna do it from the step which failed. I know there is a transaction swf_xi_swpr to do it. Is this transaction usefull? Can somebody explain me how does it work? and how to

  • Why does my new saved swatch not appear in the Swatches panel when I open a new document?? Thanks :)

    I can create a new swatch and save it. It appears in the Swatches panel. But when I close (or save and close) the document, then open a new one/existing old one, my new swatch is no longer in the Swatches panel!? I have tried finding the answer on fo