עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

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.

ג'אווה - שרשת חוליות

Featured Replies

פורסם

אני צריך לכתוב פעולה שתבנה שרשת חוליות בעורך X עם ערכים אקראיים.

אני לא מצליח לחשוב על איך ליצור את החוליה ושיהיה לה את ה NEXT :s07:

פורסם
  • מחבר

לא, אני עושה בלי LIST, רק עם ה NODE

והגעתי למשהו אבל זה מחזיר רק חוליה אחת, אולי אני מחזיר את ההפניה לא הכונה:

public static Node<Integer> createRandomChain(int numNodes)
{
Random rnd = new Random();
int num = rnd.nextInt(100);
Node<Integer> randomChain = new Node<Integer>(num);
Node<Integer> myChain = randomChain;
for (int i = 0; i < numNodes; i++)
{
num = rnd.nextInt(100);
Node<Integer> temp = new Node<Integer>(num);
randomChain.setNext(temp);
randomChain = randomChain.getNext();
}
return myChain;
}

פורסם

מה זאת אומרת "מחזיר רק חוליה אחת"?

מה קורה כשאתה עושה לה getNext?

פורסם
  • מחבר

מה זאת אומרת "מחזיר רק חוליה אחת"?

מה קורה כשאתה עושה לה getNext?

חחח.. לא, בסדר זה עובד.

ברור שזה יחזיר רק חוליה אחת... את ההדפסה של כל השרשת עושים כבר בתוכנית הראשית xD

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

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.