pointer concept

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • uppili4chi
    New Member
    • Oct 2007
    • 14

    pointer concept

    good morning sir,

    I need to use pointer concept in Java but there is no pointers in Java. is there any alternate to pointer in Java. call by reference in array....
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    Why do you need to directly manipulate pointers in Java? Can you explain your problem a little more clearly?

    Java actually does have pointers all over the place - when you say

    [CODE=java]String myString = new String();[/CODE]

    myString is technically a pointer to a String object. Java is very 'user-friendly' by hiding this implementation from you.

    Comment

    • uppili4chi
      New Member
      • Oct 2007
      • 14

      #3
      Originally posted by Ganon11
      Why do you need to directly manipulate pointers in Java? Can you explain your problem a little more clearly?

      Java actually does have pointers all over the place - when you say

      [CODE=java]String myString = new String();[/CODE]

      myString is technically a pointer to a String object. Java is very 'user-friendly' by hiding this implementation from you.
      i will explain you.
      i created an array s[5];
      and i created another array i want store this array like in this array (Note:- one array like s[] i have to store many array)
      if i store the address of that array by using pointer i don it c. how i want to over come this problem...

      Comment

      • uppili4chi
        New Member
        • Oct 2007
        • 14

        #4
        Originally posted by uppili4chi
        i will explain you.
        i created an array s[5];
        and i created another array i want store this array like in this array (Note:- one array like s[] i have to store many array)
        if i store the address of that array by using pointer i don it c. how i want to over come this problem...

        this is the code in c:

        1.
        double arr[5] = { 1, 2, 3, 4, 5};
        2.
        double mat[5][5];
        3.
        double * matp[5];
        4.

        5.
        mat[1] = arr; // Won't work
        6.
        matp[1] = arr; // Works
        7.

        8.
        // Note how the syntax is the same
        9.
        mat[1][2] = 77;
        10.
        matp[1][2] = 77;

        Comment

        • uppili4chi
          New Member
          • Oct 2007
          • 14

          #5
          Originally posted by uppili4chi
          i will explain you.
          i created an array s[5];
          and i created another array i want store this array like in this array (Note:- one array like s[] i have to store many array)
          if i store the address of that array by using pointer i don it c. how i want to over come this problem...
          Code:
           
                double arr[5] = { 1, 2, 3, 4, 5};
                double mat[5][5];
                double *  matp[5];
                mat[1] = arr;      // Won't work
                matp[1] = arr;   // Works
                //  Note how the syntax is the same
                mat[1][2] = 77;
                matp[1][2] = 77;
          this is the code what i told before

          Comment

          Working...