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 6982855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:20:35+00:00 2026-05-27T18:20:35+00:00

For Example if I Create array of object And assing data… short version of

  • 0

For Example if I Create array of object
And assing data…

short version of problem.
array[0].init(“ce”, 2)
array[1].init(“nh”, 2)

Output… Of array[0]
Will be same as array[1]
But why? what’s wrong? I need.. not same results

Here is code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.lang.Math;


public class Gra_ulamki {

    /**
     * @param args the command line arguments
     */

   public static ulamek[] tab_ulamkow;
   public static void main(String[] args) 
   {

         tab_ulamkow = new ulamek[30];


         tab_ulamkow[0] = new ulamek();
         tab_ulamkow[0].init("dd", 5);

         tab_ulamkow[1] = new ulamek();
         tab_ulamkow[1].init("dde", 8); 

         System.out.println("poz x --" + tab_ulamkow[0].x + "-- y poz " + tab_ulamkow[0].y);
          System.out.println("poz x --" + tab_ulamkow[1].x + "-- y poz " + tab_ulamkow[1].y);

         // TODO code application logic here
         //new GUI();
         //new GUI();
    }

}

class ulamek
{
public static String ch_v;
public static int x = 0, y = -5, y_max = 325;


public void init(String a, int number)
{
    this.ch_v = a;

   // przypisanie x
    this.x = number;    
}


public void move()
{


    // restart pozycji w osi y
    if(this.y < y_max)
    {
        this.y += +1;
    }
    else
    {
        this.y = -5;
    }

}

}

Thank You for help

  • 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-27T18:20:36+00:00Added an answer on May 27, 2026 at 6:20 pm

    If a data member is static, this means that it is shared by all instances of the class:

    public static String ch_v;
    public static int x = 0, y = -5, y_max = 325;
    

    Remove the two static modifiers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I create an array of multiple dimensions? For example, I want an
In the following example i can create an object dynamically via a string; however,
I need to suck data from stdin and create a object. The incoming data
I want to create a helper object that will work the following way: It
I have a method that will provide an array of model object. Some of
I mean, is there a coded language with human style coding? For example: Create
Rep steps: create example .NET form application put a TextBox on the form wire
In this example I create three buttons 'one' 'two' 'three'. When clicked I want
I am trying to make a webpage with Ajax. Example: I create a Perl/CGU
I have a table similar to this: CREATE TABLE example ( id integer primary

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.