Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5980947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:52:26+00:00 2026-05-22T21:52:26+00:00

Background I am working with functions which which passes arguments as pointers. I need

  • 0

Background

I am working with functions which which passes arguments as pointers. I need to convert a function which is written in C to JAVA with the same behavior as in C. I am developing for Android in Eclipse under Windows.

C Function Example

int testFunction( char* firstName, char* SecomdName, char* lastname, int age);

This function takes 3 pointers to char values and initializes them, so in C I can write something like the following to initialize all three pointers:

char* v1, v2, v3;
int res = testFunction(v1, v2, v3, 54);

After the call to testFunction, the variables v1, v2, v3 will be initialized with some values.

JAVA Function Example

int testFunction( String firstName, String secondName, String lastName, int age);

This is the same function as in C but written in JAVA, however in JAVA there are no pointers which means that I can’t write something like this:

String v1, v2, v3;
testFunction(v1, v2, v3, 54);

Question:

What can I do to get the same initialization behavor for my JAVA function as in the C example? Is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:52:27+00:00Added an answer on May 22, 2026 at 9:52 pm

    There’s a few things you could do. You could create a bean class that contains the fields you want to create, ie something like:

     public class Names {
         String firstName;
         String secondName;
         String lastName;
         int returnValue;
    
         // getters/constructors etc ommitted...
     }
    

    Your testFunction could then instantiate a Names object and return it, ie.

     Names names = testFunction(int age);
     String firstName = names.getFirstName();
     // etc... 
    

    An alternative, if you’re dealing with Strings is to pass through StringBuilder objects, ie

    int testFunction(StringBuilder firstName, StringBuilder secondName, StringBuilder lastName, int age) {
       // Use StringBuilder methods such as append to create the strings eg...
       firstName.append("Bob");
    }
    

    Then elsewhere in your code you could use…

    StringBuilder firstNameBuilder = new StringBuilder();
    StringBuilder secondNameBuilder = new StringBuilder();
    StringBuilder thirdNameBuilder = new StringBuilder();
    
    testFunction(firstNameBuilder, secondNameBuilder, thirdNameBuilder, 84);
    
    String firstName = firstNameBuilder.toString();  // firstName now equals "Bob"
    /// etc...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background I am working on a phonetic converter program which converts english text into
I'm working on a background service which needs to ask several users' iTunes settings
Background I am working on a legacy small-business automation system (inventory, sales, procurement, etc.)
Background: We have an offshore group working up a Silverlight 2 prototype for us.
I am working on a background program that will be running for a long
Background Lately I've become a fanatic that everything I type while working on a
i'm working with a multi-threaded program (using pthreads) that currently create a background thread
I am working with: #top ul li.corner span.right-corner:hover { background-image:url(images/corner-right-over.gif); width:4px; height:15px; float:left; }
First a bit of background. I have been working on the MS platform for
Background: At my company we are developing a bunch applications that are using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.