<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[עזרה | java me]]></title><description><![CDATA[<p dir="rtl">התחלתי להכין יישום בj2me (גימטריאון), אבל יש מניעות... <img src="https://tchumim.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61f.png?v=cf1b4e11576" class="not-responsive emoji emoji-android emoji--worried" style="height:23px;width:auto;vertical-align:middle" title="😟" alt="😟" /><br />
דבר ראשון - זה לא נותן לעשות switch לסטרינג, אלא רק לint<br />
דבר שני - עשיתי בif else ונותן שגיאה בזמן ריצה<br />
לפי השגיאות אני חושב שהטעות נמצאת בשורות האלה:</p>
<pre><code>for (int i = 0; i &lt;= str.length(); i++) {
           String sub = str.substring(i, i + 1);
</code></pre>
<p dir="rtl">הקוד המלא:</p>
<pre><code>import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;

public class gematrionMIDlet extends MIDlet implements CommandListener {
  private Display display;
  private Form form = new Form("גימטריאון");
  private Command submit = new Command("חישוב", Command.SCREEN, 1);
  private Command exit = new Command("יציאה", Command.EXIT, 1);
  private TextField textfield = new TextField("כתוב כאן מילים לחישוב", null, 1000, TextField.ANY);
  private StringItem stringitem = new StringItem(null, "0");

  public gematrionMIDlet() {
    display = Display.getDisplay(this);
    form.addCommand(exit);
    form.addCommand(submit);
    form.append(textfield);
    form.append(stringitem);
    form.setCommandListener(this);
  }

  public void startApp() {
    display.setCurrent(form);
  }

  public void pauseApp() {
  }

  public void destroyApp(boolean unconditional) {
  }

  public void commandAction(Command command, Displayable displayable) {
    if (command == submit) {
    	String str = textfield.getString();
        int num = 0;
        for (int i = 0; i &lt;= str.length(); i++) {
           String sub = str.substring(i, i + 1);
           if (sub == "א")
        	   num += 1;
           else if (sub == "ב")
        	   num += 2;
           else if (sub == "ג")
        	   num += 3;
           else if (sub == "ד")
        	   num += 4;
           else if (sub == "ה")
        	   num += 5;
           else if (sub == "ו")
        	   num += 6;
           else if (sub == "ז")
        	   num += 7;
           else if (sub == "ח")
        	   num += 8;
           else if (sub == "ט")
        	   num += 9;
           else if (sub == "י")
        	   num += 10;
           else if (sub == "כ" || sub == "ך")
        	   num += 20;
           else if (sub == "ל")
        	   num += 30;
           else if (sub == "מ" || sub == "ם")
        	   num += 40;
           else if (sub == "נ" || sub == "ן")
        	   num += 50;
           else if (sub == "ס")
        	   num += 60;
           else if (sub == "ע")
        	   num += 70;
           else if (sub == "פ" || sub == "ף")
        	   num += 80;
           else if (sub == "צ" || sub == "ץ")
        	   num += 90;
           else if (sub == "ק")
        	   num += 100;
           else if (sub == "ר")
        	   num += 200;
           else if (sub == "ש")
        	   num += 300;
           else if (sub == "ת")
        	   num += 400;
           }
    	this.stringitem.setText(Integer.toString(num));
    } else if (command == exit) {
      destroyApp(false);
      notifyDestroyed();
    }
  }
}

</code></pre>
<p dir="rtl">השגיאה:<br />
<img src="/assets/uploads/files/1620950477275-nokia-c2-01.png" alt="Nokia C2-01.png" class=" img-fluid img-markdown" /></p>
<p dir="rtl">דבר שלישי - איך אפשר לעשות שהחישוב יהיה אוטומטית, ולא בלחיצה על 'חישוב' (כמו oninput)?</p>
<p dir="rtl">בjavascript וactionscript הצלחתי לעשות את היישום</p>
<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%90%D7%9C%D7%99%D7%A9%D7%99" aria-label="Profile: אלישי">@<bdi>אלישי</bdi></a> <a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%93%D7%95%D7%91" aria-label="Profile: דוב">@<bdi>דוב</bdi></a> <a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%90%D7%91%D7%99%D7%99" aria-label="Profile: אביי">@<bdi>אביי</bdi></a> אשמח לעזרה..<br />
תודה רבה!</p>
]]></description><link>https://tchumim.com/topic/11208/עזרה-java-me</link><generator>RSS for Node</generator><lastBuildDate>Sun, 15 Nov 2026 09:42:11 GMT</lastBuildDate><atom:link href="https://tchumim.com/topic/11208.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 May 2021 00:07:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to עזרה | java me on Sun, 16 May 2021 07:50:02 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A0-%D7%A0%D7%97" aria-label="Profile: נ-נח">@<bdi>נ-נח</bdi></a> אפשר בבקשה את הJAR? תודה</p>
]]></description><link>https://tchumim.com/post/122804</link><guid isPermaLink="true">https://tchumim.com/post/122804</guid><dc:creator><![CDATA[LindoorsOS]]></dc:creator><pubDate>Sun, 16 May 2021 07:50:02 GMT</pubDate></item><item><title><![CDATA[Reply to עזרה | java me on Fri, 14 May 2021 12:53:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid" aria-label="Profile: dovid">@<bdi>dovid</bdi></a> תודה! זה עובד, וגם למדתי דברים חדשים.<br />
לא הצלחתי עם העדכון של התוצאה (נראה לי שהקישור שהבאת זה לjava, לא לjava me)</p>
<p dir="rtl">עריכה: הצלחתי עכשיו!<br />
אשריך!!!!<br />
<img src="/assets/uploads/files/1620996813996-nokia-c2-01.png" alt="Nokia C2-01.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://tchumim.com/post/122791</link><guid isPermaLink="true">https://tchumim.com/post/122791</guid><dc:creator><![CDATA[נ נח]]></dc:creator><pubDate>Fri, 14 May 2021 12:53:52 GMT</pubDate></item><item><title><![CDATA[Reply to עזרה | java me on Fri, 14 May 2021 10:05:45 GMT]]></title><description><![CDATA[<p dir="rtl">בקשר לריענון אוטומטי של התוצאה בעת שינוי הטקסט בדוק פה<br />
<a href="https://stackoverflow.com/a/3953219/1271037" target="_blank" rel="noopener noreferrer nofollow ugc">https://stackoverflow.com/a/3953219/1271037</a></p>
]]></description><link>https://tchumim.com/post/122786</link><guid isPermaLink="true">https://tchumim.com/post/122786</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Fri, 14 May 2021 10:05:45 GMT</pubDate></item><item><title><![CDATA[Reply to עזרה | java me on Fri, 14 May 2021 10:06:53 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A0-%D7%A0%D7%97" aria-label="Profile: נ-נח">@<bdi>נ-נח</bdi></a> אמר ב<a href="/post/122767">עזרה | java me</a>:<br />
תראה את הקוד שהבאת:</p>
<pre><code>   for (int i = 0; i &lt;= str.length(); i++) {
</code></pre>
<p dir="rtl">זה אומר ב"סיבוב" הראשון i יהיה שווה 0. כמה הוא יהיה בסיבוב האחרון? str.length() שהרי תנאי היציאה הינו רק כאשר i יהיה <strong>גדול</strong> מהאורך. כלומר אם מדובר במילה אבא, הlength הוא 3, אז יהיה 0, 1, 2, 3 וזה מיותר כי הרי יש לנו רק שלוש אותיות.<br />
אז ראשית תוריד את השווה, שיהיה רק  i &lt; str.length() ואז כשיהיה 3 ה"סיבוב" לא יתבצע, ויהיה לנו רק 0, 1, 2.</p>
<p dir="rtl">בקשר לקוד</p>
<pre><code>String sub = str.substring(i, i + 1);
</code></pre>
<p dir="rtl">יש מתודה פשוטה יותר לקחת אות בודדת:</p>
<pre><code>    char sub = str.charAt(i);
</code></pre>
<p dir="rtl">אבל אז תצטרך לעדכן קצת את הקוד שלך, להחליף בכל מקום את אותיות ההשוואה ממרכאות כפולות (שזה סטרינג) למרכאה בודדת (שזה char = תו בודד).</p>
]]></description><link>https://tchumim.com/post/122785</link><guid isPermaLink="true">https://tchumim.com/post/122785</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Fri, 14 May 2021 10:06:53 GMT</pubDate></item></channel></rss>