Array_reverse() in PHP -- ist it possible in JAVA?

Hello JAVA Community,
I'am a newbe in JAVA, an older C++/PHP Developer.
How can I do that in JAVA:
// PHP Code:
$input  = array(3,4,6,6,7,8,9);
$result = array_reverse($input);thank you very much for your kind solutions..
rgds emile

>
Dear Aurelius,
thank very much but im am just looking of an "method", ist there any method or not? That is my question.There is not one built in by default, but I showed you both how to do it and how to make it specially built into the system for you.
Emil_Orlowski wrote:
An older C++ developer, you say? I don't mean to be condescending, but you never had to do anything like
this in C++? The C++ I know is the land of "You have to do everything yourself."Please do not be angry with me! I have difficulties to comprehend it, why one is busy with unnecessary details? It is just about a PHP function; I search for an equal function in Java.The answer simply could be "there is nothing something like that in Java".Do not worry; I am not angry with you.
I see that you have difficulty comprehending it, as you say. Based on your writing, it appears that English is not your first language. Is that correct? I did not realise this at first. I will assume any misunderstanding is due to this language barrier.
>
It is just about a PHP function; I search for an equal function in Java.The answer simply could be "there is nothing something like that in Java".
>
Someone else has pointed out that it does exist in Java, though it is for a different data structure and not specifically for an array.
You can put what I gave you into a method and call that, or you can use a Collection instead of an array and use the Collections reversal method that someone else mentioned.
One last thing, concerning terminology, just in case you did not realise it (I assume not since you write "method" in quotation marks) since you are used to dealing with C++ and PHP. The term method refers to a function which is a member of a class or object, and, since almost all data are objects in Java, all functions in Java are methods. Everyone around here will say method instead of function.
I hope all this helps you. Good fortune to you in your Java endeavors.

Similar Messages

  • Is down casting possible in Java objects(reference variables)?

    I hope, Java up casting and down casting is possible in Java primitive variables like int float and so on.
    My doubt is,Does in object of Java(reference variables) support down casting?

    makpandian wrote:
    the ques i asked here is popped from my mind.We know that.
    But i did not get answer .Because you didn't do any research.
    Than s why i ask this here..That's the wrong approach. Do some research first. Use google, a textbook, a tutorial, the JLS, write some code, etc. etc.
    After spending time and effort doing that, if you still have questions, indicate clearly what you read and what part you didn't understand. The way you're doing it is NOT an effective way to learn, and it's a waste of everyone's time.

  • Is it possible in java to pass reference of object in Java?

    Hello,
    I'm relativily new to Java but I have "solid" knowledge in C+ and C# .NET+.
    Is it possible in java to pass reference of object in Java? I read some articles about weakreferences, softreferences, etc. but it seems that it's not what I'm looking for.
    Here is a little piece of code I wrote:
    package Software;
    import java.util.Random;
    * @author Rodrigue
    public class RandomText
        private Random rand = new Random();
        private Thread t;
        private String rText = "Rodrigue";
        public RandomText()
            t = new Thread()
                @Override
                public void run()
                    try
                        while(true)
                            UpdateText();
                            sleep(100);
                    catch(InterruptedException ex)
            t.start();
        private void UpdateText()
            int i = rand.nextInt();
            synchronized (rText)
                rText = String.valueOf(i);
        public String GetText()
            return rText;
    }It's just a class which start a thread. This class updates a text with a random integer 10 times per second.
    I would like to get a reference on the String rText (like in C++ ;) yes I know, I must think in Java :D). So, like that, I could get one time the reference, thanks to the GetText function, and update the text when my application will repaint. Otherwise, I always have to call the GetText method ... which is slow, no?
    Are objects passed by reference in java? Or, my string is duplicated each time?
    Thank you very much in advance!
    Rodrigue

    disturbedRod wrote:
    Ok, "Everything in Java is passed by value. Objects, however, are never passed at all.". Reference of object is passed by value too.
    But, how to solve my problem in Java_? I have an object which is continually modified in a thread. From an another side, this object is continually repainted in a form.I'm not sure I totally understand your problem. If you pass a reference to an object, then both the caller and the method point to the same object. Changing the internal state of the object (e.g. by calling a setter method) through one reference will be observed through both references, since they both point to the same object.
    No, calling a method is not particularly slow. Especially if it's just a simple getter method that returns the value of a member variable.
    If this is happening in a multithreaded context, you'll have to use proper synchronization to ensure that each thread sees the others' changes.

  • Is it possible in java 5 to generate a XML document from object?

    Hi all ,
    Is it possible in java 5 to generate a XML document from object?if yes, how do I implement this?
    ~Regards

    : /\ P:^P would look better. ;)
    0 0
      >
      U

  • Ist it possible to use icloud with iphone3g

    ist it possible to use icloud with iphone3g

    The only formally supported thing is manually setting up an iCloud mail account. Even though Find My Phone will seemingly connect my iPhone 3G doesn't show up as it being connected through the iCloud web site.
    http://support.apple.com/kb/HT4864

  • Captcha on BSP using java is possible? Java allowed in BSP?

    Hello to all,
    My client ask for a captcha on a BSP page of autoregister of SRM module. I have found the posts using PHP
    [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4e539c30-0501-0010-3291-a4c4193a6414|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4e539c30-0501-0010-3291-a4c4193a6414]
    [/people/eddy.declercq/blog/2005/09/13/die-mensch-maschine|/people/eddy.declercq/blog/2005/09/13/die-mensch-maschine]
    but now the client wants to be made with Java. Is possible to introduce a java call into BSP? i dont think so but you can confirm.
    Thanks for all,
    Nacho

    Hello to all,
    My client ask for a captcha on a BSP page of autoregister of SRM module. I have found the posts using PHP
    [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4e539c30-0501-0010-3291-a4c4193a6414|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4e539c30-0501-0010-3291-a4c4193a6414]
    [/people/eddy.declercq/blog/2005/09/13/die-mensch-maschine|/people/eddy.declercq/blog/2005/09/13/die-mensch-maschine]
    but now the client wants to be made with Java. Is possible to introduce a java call into BSP? i dont think so but you can confirm.
    Thanks for all,
    Nacho

  • N:1 Mapping Possible using Java Mapping?

    All,
    Is it possible to do a N:1 mapping using Java Mapping?
    If yes , how?
    Reason for this question is that the execute() of the Java Mapping is going to take the source / request message as the InputStream . In the case of N:1 mapping , as we have multiple messages , how will they be send to the InputStream? Will both the messages be sent combined into the InputStream? Will the MESSAGES tag be embedded into the input stream?
    Regards,
    Bhavesh

    Hi @ll;
    i try the same.
    to conduct a java mapping with 2 input structures that fills one target structure.
    This mapping is part of a Integrationprocess.
    I tested the mapping at the Integration Repository (Interface mapping) with the structure given by henrique and it works fine without any error.
    At runtime this structure looks like this (different prefix)
    <?xml version="1.0" encoding="UTF-8"?>
    <sxi:Messages xmlns:sxi="http://sap.com/xi/XI/SplitAndMerge">
         <sxi:Message1>
              <YOURXML1>...</YOURXML1>
         </sxi:Message1>
         <sxi:Message2>
              <YOURXML2>...</YOURXML2>
         </sxi:Message2>
    </sxi:Messages>
    As I put it in the Integrationprocess unfortunately a strange error arises.
    The trace Workflow-Protocoll shows following error.
    <Trace level="2" type="T">Call method execute of the application Java mapping com.endress.infoserve.xi.mapping.MergeConfigStore_IdocOrder </Trace>
    <Trace level="2" type="T">Java mapping com/endress/infoserve/xi/mapping/MergeConfigStore_IdocOrder completed. (executeStep() of com.endress.infoserve.xi.mapping.MergeConfigStore_IdocOrder </Trace>
    <Trace level="1" type="T">Parsing error after multi mapping.Expected Message<i> instead of IDOC </Trace>
    I can't make head nor tail of it.
    what´s the mistake?
    can anybody please help me?
    Thanks in advance
    Kind regards

  • Is this possible: SAP Java Connector - XI - R3 with XI RFC Adapter?

    Hi,
    I try to call a RFC on a remote R/3 System over the XI Server in a Java Application with SAP Java Connector.
    I have configured a RFC Sender Adapter in XI. I get the
    following Exception:
    "lookup of alternativeServiceIdentifier via CPA-cache failed for channel 'SenderChannel_RFC"!
    Is this scenario possible? Or do the connection from
    a SAP Java Connector App to the XI RFC Adapter not work?
    You can't set the Client and System ID of a Third-Party or
    Standalone Java system in the SLD.
    Thanks for any help!
    Regards
    Wolfgang

    Hi,
    We use a JCO for directly connecting to sap systems.
    In that case we need not use any XI also.
    But if you want to use RFC adapter and java application the best way is to use java proxies as sender and reciever as RFC adapter.
    I donot think there is any  architectural significance in using rfc adapter of XI while using JCO.
    Let me know if I mis-understood the context.

  • Fast file system search not possible in java?

    hi,
    I'd like to find all xml files on a disk as quickly as possible. The simple implementation takes far too long (e.g. over 30 seconds for a disk with 10,000 files and 1000 folders).
    This is a network drive, but the reason I think 30 seconds is slow is that the equivalent C code does it in much less time (over the same network conditions)
    I've seen it run on a drive with 200000 files and 30000 folders, and this takes between 10-15 minutes, while C code takes around 1-2 minutes.
    I'm not sure what the C code does exactly, and it may have access to much better OS calls than java can assume.
    The only three things I can think of are
    1) try to use fewer file objects (can't see a way of doing this)
    2) try threading (i've done small tests before and not got any gain)
    3) try using FileFilters (i've done small tests here too and not got any gain - I think they just implement what you'd do without them anyway..)
    the other option is JNI but this is very bad since I need to run any many platforms..
    profiling shows that most time is spent in the native code
    17.0% 0 + 287 java.io.WinNTFileSystem.list
    10.7% 0 + 181 java.io.WinNTFileSystem.getBooleanAttributes
    but I've heard that switching between java/native is very expensive? so there may be benefits from doing it all in one go somehow?
    any help would be really appreciated,
    thanks,
    asjf
    ps. caching the file list is not really an option since it needs to run fast on new targets

    heres some code that is much faster when I/O blocking is the main problem (seems to work much better on network drives..)
    it uses a slightly bizarre (?) thread pool of workers that process a list of Invocations.
    (this is one big file Pool.java)
    asjf
    ps. I don't normally write code like this :)
    import java.util.*;
    import java.lang.reflect.*;
    import java.io.*;
    public class Pool {
    List invocations;
    public void invoke(Invocation a){
    invocations.add(a);
    synchronized(invocations) {
    invocations.notify();
    //System.out.println("Added an invokation");
    ThreadGroup threads;
    Set pool;
    Pool(int noThreads){
    pool = new HashSet();
    threads = new ThreadGroup("Pool of "+noThreads);
    invocations = Collections.synchronizedList(new LinkedList());
    for(int i=0; i<noThreads; i++){
    Worker w = new Worker(i+" of "+noThreads);
    Thread t = new Thread(threads, w);
    pool.add(w);
    t.start();
    new Thread(new Runnable() {
    public void run(){
    try{
    while(poolActive) {
    int active = 0;
    for(Iterator i = pool.iterator(); i.hasNext(); ){
    Worker w = (Worker) i.next();
    if(w.working) active++;
    Thread.sleep(3000);
    System.out.println(invocations.size() + " : " + active);
    }catch(Exception e){
    e.printStackTrace();
    }).start();
    volatile boolean poolActive=true;
    public void join() {
    try {
    boolean alldone = false;
    while(!alldone) {
    alldone=true;
    for(Iterator i = pool.iterator(); i.hasNext(); ){
    Worker w = (Worker) i.next();
    if(w.working)
    alldone=false;
    if(invocations.size()>0)
    alldone=false;
    Thread.sleep(2000);
    }catch(Exception e){
    e.printStackTrace();
    //System.out.println("--------------------------> all done");
    poolActive=false;
    synchronized(invocations) {
    invocations.notifyAll();
    public void status() {
    threads.list();
    public static void main(String [] arg) throws Exception {
    long time=-System.currentTimeMillis();
    Pool pool = new Pool(200);
    Enumerater e = new Enumerater(pool);
    Invocation in = new Invocation(null,Enumerater.getXML, new Object [] {new File(arg[0]),e.result});
    pool.invoke(in);
    //pool.status();
    pool.join();
    time+=System.currentTimeMillis();
    System.out.println("Time taken "+time+"\nFound "+e.result.size());
    class Worker implements Runnable {
    String name;
    volatile boolean working;
    public Worker(String name) {
    this.name = name;
    public void run() {
    try {
    working=false;
    while(poolActive) {
    Invocation i = null;
    synchronized(invocations) {
    while(poolActive && invocations.size()==0){
    invocations.wait();
    //System.out.println("Hello from "+name);
    if(invocations.size()!=0) {
    working=true;
    i = (Invocation) invocations.remove(0);
    //System.out.println(name+" processed: "+i);
    if(i!=null)
    i.result=i.method.invoke(i.o,i.arg);
    working=false;
    }catch(Exception e){
    e.printStackTrace();
    class Invocation {
    Object o;
    Method method;
    Object [] arg;
    Object result;
    public String toString(){
    return o+" "+method+" "+arg;
    public Invocation(Object o, Method method, Object [] arg) {
    this.o=o;
    this.method=method;
    this.arg=arg;
    this.result=null;
    class Enumerater {
    Set result;
    static Pool pool;
    static Method getXML;
    static {
    try {
    getXML = Enumerater.class.getDeclaredMethod("getXML",new Class [] {File.class,Set.class});
    }catch(Exception e){
    e.printStackTrace();
    Enumerater(Pool p){
    pool = p;
    result = Collections.synchronizedSet(new HashSet());
    public static void getXML(File file, Set result) {
    File [] children = file.listFiles();
    if(children==null)
    System.out.println(file.getAbsolutePath()+" has null children");
    else
    for(int j=0; j<children.length; j++)
    if(children[j].isDirectory()) {
    Invocation in = new Invocation(null,getXML, new Object [] {children[j],result});
    pool.invoke(in);
    else
    if(children[j].getName().toUpperCase().endsWith(".XML"))
    result.add(children[j]);

  • Can php pass info to a java client-side program?

    hi!
    can a php script on a remote server (activated thru command line or whatever) pass data over the internet to a java client-side program? if so, how?
    thanks!

    if it is listening to a known port, how would the data be passed?
    thanks!
    Not unless the Java program is listening on a known
    port.
    Yours,
    Tom

  • Is it possible in java

    hey could any one tell me whether the task given below is possible
    if so what i hve to study plz suggest
    Sends a HTTP Post message with the specified parameters and then verifies the return value is a 200 series return

    Sends a HTTP Post message with the specified
    parameters and then verifies the return value is a
    200 series returnYes. Look at the java.net package.

  • JAVA, JAVA WEB dynpro and possibility of JAVA workflow

    Hi all
    Just a take here -- I'm just getting some feelers on the way WF SHOULD be going in future.
    Since starting to use the JAVA WD system and netweaver developer studio it seems that having to encapsulate a lot of NEW Workflows as ABAP objects is going "Backwards". (Note I said NEW not EXISTING applications)
    I understand that some compatability with existing systems needs to be maintained but if your user is doing all his applications from a Portal you really need the WF's to be triggered from the portal via say WEB SERVICES.
    I find I'm actually using the older ERP / ECC 6.0 R/3 systems these days purely as DATA repositories and from a JAVA program can often retrieve the data via standard BAPI's and RFC calls in a JAVA or Portal application.
    Isn't it about time that the workflow system as a whole was made much more JAVA and PORTAL friendly --since this is where more and more people are doing their developments from.
    Since switching more or less full time over to JAVA WEB DYNPRO developments the whole development time is completed MUCH QUICKER and with many many less mistakes.
    ABAP Web dynpro is also OK but it's still a little bit of a nightmare compared with JAVA when you need a lot of WEB SERVICES.
    Some WF's obviously will need to remain ABAP based but newer custom WF's IMO should be WEB DYNPRO and WEB SERVICE based.
    I can't think of too many large organisations who aren't making more and more use of Portals these days -- so C'mon SAP -- provide some proper Web hooks into WF's instead of us having to go through hoops and rings of writing LAST CENTURY's code to get stuff to work through a Portal.
    Cheers
    jimbo

    Hi,
    Have you checked the new BPM tool that SAP is offering? I think that it is definately a big step into to the drection that you are describing. I haven't really checked all its features and the technology that is is based on, so I am not the biggest expert of this matter.
    Check for example this article to get an overview: http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b06c49b2-ac63-2c10-3d8d-d17b817ba4ca?quicklink=nw-bpm&overridelayout=true
    Of course it will be a long road before this new tool will (if it will ever) replace the old ABAP based workflow engine.
    I wouldn't totally agree with all the points that you presented (ABAP WD being a nighmare, etc.). Actually I think that the direction (at least in some parts) is the opposite. For example SAP seem to have replaced their "old" travel management applications (Java WD) with new ABAP WD applications, so I see that they believe more in ABAP than Java (of course there might be some financial & other reasons behind this also.). In my opinion WDA has so many advantages compared to WDJ, that I would consider carefully the options when choosing the technology (the possible better(?) compatibilitly with web services might be one of the reasons).
    Regards,
    Karri

  • Php with xsl on Sun Java Web Server 7.0

    Hi anyone,
    i installed php as nsapi via phppack. Now i need xsl support in php. I've tryed to compile php with the following line (php 5.2.6):
    ./configure with-nsapi=/export/netscape_71 enable-force-cgi-redirect with-gettext with-zlib --with-xsl=/usr/lib64/php5/extensions
    magnus.conf, obj.conf and mime.types are assimilate to this article:
    http://developers.sun.com/webtier/reference/techart/php2.html
    After compiling, i copy the libphp5.so in the .plugins/php/ dir an restart the webserver.
    He stops with this message:
    failure: CORE2253: Error running Init function load-modules: dlopen of /export/netscape_71/plugins/php/libphp5.so failed (/export/netscape_71/plugins/php/libphp5.so: wrong ELF class: ELFCLASS64)
    failure: server initialization failed
    What's going wrong?
    How i get xsl Support on Sun Java Web Server?
    thanks!

    essential wrote:
    ./configure with-nsapi=/export/netscape_71 enable-force-cgi-redirect with-gettext with-zlib --with-xsl=/usr/lib64/php5/extensionsYou are pointing to 64-bit library path. Change it to 32-bit library path.
    failure: CORE2253: Error running Init function load-modules: dlopen of /export/netscape_71/plugins/php/libphp5.so failed (/export/netscape_71/plugins/php/libphp5.so: wrong ELF class: ELFCLASS64)
    failure: server initialization failedThis means that it expects a 32-bit library but it found a 64-bit one.

  • Is restoration possible from java export and offline db backup

    Hi,
    We patched our sandbox from sps9 to sps11, but unfortunately we did not
    success doing it in prodcution. We have production servers CI export
    and offline backup ( we do not have DB export ) of SPS9, Please suggest
    can we reproduce our production system in to sandbox using CI export
    and offlinebackup of SPS9.
    If it is, then please suggest the way through which we proceed and get
    it as early as possible.
    Thanking your for your eraliest help and response.
    Regards,
    Nizam

    edit:  ok, I was confused by what you said before.  I think you are asking "how to create a sandbox from backup of production".
    First, I'm not sure if SAP has a tool to simpily change the SID, server names, system number, etc.
    To do this, you'll have a lot of fun (sarcastic):
    1. Restore offline backup from production to sandbox.
    2. Make sure your database permission fro SAP<sandboxSID>DB is set right.  Manually copy the permissions from the production database server just to be sure.
    3. Change all objects in the database from SAP<productionSID>DB schema to SAP<sandboxSID>DB.
    4. If the user SAP<productionSID>DB exists in the database, you can drop it at this time.  All object schemas should've been converted to SAP<sandboxSID>DB
    5. Run the config tool, click no when asked to use default DB credentials.  In the DB login information page, change the server from production to sandbox.  Change the user from SAP<productionSID>DB to SAP<sandboxSID>DB.
    4. Close config tool and open again, try to connect.  This is the first step, you MUST be able to connect successfully.
    5.  You now need to go through ALL entries in Java Administrator and Config Tool, to ...
      - Change all references to the production application server name to the sandbox server name.
      - Change all references to the production database server name to sandbox server name.
      - Change all reference to SAP<prodcutionSID>DB schema to SAP<sandboxSID>DB schema.
      - If the system number is different, you must locate all port, system number, etc. and change them too.
    6.  Lastly, there are some .config and .properties file in the cluster folder in the kernel directories.  You must ...
      - Change all references to the production application server name to the sandbox server name.
      - Change all references to the production database server name to sandbox server name.
      - Change all reference to SAP<prodcutionSID>DB schema to SAP<sandboxSID>DB schema.
      - If the system number is different, you must locate all port, system number, etc. and change them too.
    Gripe to SAP:  What the H guys ... ABAP = 4 places where I have to change when I shuffle systems around.  JAVA = like 4 million places.  Why why why why why why!!!!! Bang head on table
    Edited by: Kevin Lin on Aug 26, 2008 10:33 AM

  • Implementing soap.jar in jdk ist not possible, wrong classpath???

    hi
    i want to run a soap example
    my problem at the moment ist, the java compiler
    isn't able to find the soappackages like org.apache.soap.rpc.*
    i changed my registryconfiguration (winnt4.0 sp6) setting the
    classpath to c:\soapinstalldir\lib\soap.jar but it doesnt work
    the serverside is running using iplanet web- and app-server with
    the apache soap plugin
    does anybody know where to copy the class-files of my application
    in order to be able to deploy and to run the application
    do i need to write a deployementdescriptor?
    if yes, how?
    thanks
    jesse blue

    Check my reply to that other thread... perhaps it will help?
    jesse blue wrote:
    hi
    i want to run a soap example
    my problem at the moment ist, the java compiler
    isn't able to find the soappackages like org.apache.soap.rpc.*
    i changed my registryconfiguration (winnt4.0 sp6) setting the
    classpath to c:\soapinstalldir\lib\soap.jar but it doesnt work
    the serverside is running using iplanet web- and app-server with
    the apache soap plugin
    does anybody know where to copy the class-files of my application
    in order to be able to deploy and to run the application
    do i need to write a deployementdescriptor?
    if yes, how?
    thanks
    jesse blue

Maybe you are looking for

  • Why? I can't use my Visa card? For assistance, contact iTunes Support at~~~

    Hi   I just want to ask why? my Visa Card can't use ??? FB to my Emil please.......                                                                                                              <Edited by Host>

  • Sharing Library Between PC and Mac

    Hello all, I recently transferred my iTunes library from the PC to an AirDisk. The annoying thing is that when I open iTunes on the Mac, it does the "Updating iTunes Library" which takes a while to complete. When I open iTunes on the PC, it does the

  • How to Determine BHCA and ACH in UCCX Environment v8.5.1

    Hi, I need to calculate the busy hour call attempts and average call handle time in a UCCX environment. I know for a UCCE you can simply run a SQL query, but I am having trouble with the UCCX. UCCX version is 8.5.1 Thank you, 

  • Not charging!!!!! Plz help

    I Hav iphone 5 bout 2 years old, it was briefly submerged in river, I opened it up and dryed out the phone with help from YouTube vids, the phone worked normally execpt camera didn't work anyway, it was working fine but when it was plugged in to char

  • Additional Data ta fields

    Hello Gurus, I am working on version ECC 6.0. The Additional data tab on the header level of the PO does not contain any fields. The fields are missing on this tab eg. Validity start date, end date , warranty etc. I require these fields on my PO as i