الانتقال إلى المحتوى
View in the app

A better way to browse. Learn more.

مجموعة مستخدمي أوراكل العربية

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

بتاريخ:

لدي مشكله في كتابة هذا البرنامج وهو لجمع عددين
public class Colculator
{
int numb1=5;
int numb2=7;
int sum=numb1+numb2;
public static void main(String agrs[])
{
System.out.println(numb1);
System.out.println(numb2);
System.out.println(sum);
}
}
والخطأ هنا
C:\Documents and Settings\sultan_net2004\My Documents\Colculator.java:8: non-static variable numb1 cannot be referenced from a static context
System.out.println(numb1);
^
C:\Documents and Settings\sultan_net2004\My Documents\Colculator.java:9: non-static variable numb2 cannot be referenced from a static context
System.out.println(numb2);
^
C:\Documents and Settings\sultan_net2004\My Documents\Colculator.java:10: non-static variable sum cannot be referenced from a static context
System.out.println(sum);
^
3 errors

Tool completed with exit code 1

بتاريخ:

عزيزى سلطان اوراكل
المشكلة بسيطة جداً

you try to reference non static variables into the static method "main"

try the following

public class Colculator
{

public static void main(String agrs[])
{
int numb1=5;
int numb2=7;
int sum=numb1+numb2;
System.out.println(numb1);
System.out.println(numb2);
System.out.println(sum);
}
}

بتاريخ:

جرب بهذا الشكل
public class Colculator

{

public static void main(String agrs[])
{
int numb1=5;
int numb2=7;
int sum=numb1+numb2;
System.out.println(numb1);
System.out.println(numb2);
System.out.println(sum);
}
}

بتاريخ:
  • كاتب الموضوع

شكرا شكرا شكرا llord و unicorn

ما تتصورا كيف فرحتي وانا اشوف الحل

مشكورين

انا قلت للمدرس لازم نحط main في البداية

  • بعد 2 شهور...
بتاريخ:

أخي سلطان

المفترض انك تخلي تعريفك num1 و num2 كما هو يكون في ال Class فوق

وفي main لازم تعرف Object يقدر يقرأ جمل الاسناد ولكي تستطيع ان تصل الى المتغيرات وهذا كل ما في الامر
اما ان تكتب وتعرف المتغيرات داخل main كانك ما عملت شي وما عرفت شو يعني Classes وشو يعني objects وشو يعني oop

هذا فقط للفائدة اخي الكريم

مع تحياتي لك بالتوفيق

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية

Account

Navigation

البحث

إعداد إشعارات المتصفح الفورية

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.