Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Hilfe!!! bei Hashtable!!!

Empfohlene Antworten

Veröffentlicht

wie kann ich in der Hashtable eine ID für jedes gespeicherte Methode vergeben!?!!??!

thx gicio

Ich versteh dein Problem nicht so ganz. Du willst also ID's vergeben? Hmmm, soweit ich weiss, geht das mit put (Object key, Object value). Der key sollte deine ID sein, das value-Object dein Element, das du speichern willst.

Solltest du nach automatischen ID's suchen, schreib Dir ne Klasse, im Singleton-Muser und da implementiere die Methoden getNextID () oder getPreviousID().

Ich wüsste sonst nicht, was du meinst.

greetz Kniffo

Hi,

hääää?? Also "jedes gespeicherte Methode", damit meinst Du wohl ein Objekt und mit ID meinst Du wohl den Key.

put(Object key, Object value)

JAVA Api lesen hat schon oft geholfen bei solchen Problemen

MfG Markus

upps!!

klar meine ich Objekte..............

(wie peinlich!! ;) )

:eek: :eek: :eek:

thx

gicio

sag ich doch ;)

soll das so aussehen?

 

// Datei Persons.java


public class Persons

{

	private String name;

	public String street;

	public int streetnr;

	public int plz;

	public String city;

   public int tel;

	public int age;

	public String secondcar;




	public void setName(String p_name)

	{


		name = p_name;

	}


	public Object put (name key, name value)

	{


	}


}

 

ALSO: das is deine Klasse, von der du bestimmt mehrere Objekte erzeugen willst:

// Datei Persons.java

public class Persons

{

private String name;

public String street;

public int streetnr;

public int plz;

public String city;

public int tel;

public int age;

public String secondcar;

public void setName(String p_name)

{

name = p_name;

}

//public Object put (name key, name value)

//{

//

//}

// Schreib noch einen Konstruktor

}

und nun schreibst du Dir (nach Eingabe der Daten o.ä.) eine Methode, an die du dieses erzeugte Objekt weiterreichst in einer anderen Klasse:

class Application

{

Hashtable htData = null;

int iCurrentID = 0;

public Application ()

{

htData = new Hashtable();

}

// stores Data in a Hashtable

public void storeData (Persons oPersons)

{

htData.put (new Integer (getNextID()), oPersons);

}

// add one to ID and return it

private int getNextID ()

{

iCurrentID ++;

return iCurrentID;

}

}

Ich hoffe, das hilft Dir ein wenig. Wenn Fragen, dann Fragen fragen. :P

greetz again

Kniffo

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.