الانتقال إلى المحتوى
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.

مساعدة في جافا Array

Featured Replies

بتاريخ:

لدي خطا في هذا الكلاس و لمدة يومين و أنا أحاول حله دون جدوى ....

package Eleve;
import java.util.ArrayList;
public class Evaluation {
 
public ArrayList<Note> notes = new ArrayList<Note>();
    
public void ajouter(ArrayList<Double> list, Note note) {
notes.add(note);
}
public static double moyenne(ArrayList<Note> notes){
double s= 0.0;
for (int i =0; i<=notes.size(); i++)
{
    s=s+notes.get(i);
    } 
      return s/notes.size();
        
}
public void resultat(){
for (int i = 0; i < notes.size(); i++) {
System.out.println("l'ensemble des notes de l'étudiant sont :" +notes.get(i));
}
System.out.println("la Moyenne est " +moyenne(notes));
}
}
 
 
الخطأ على مستوى s=s+notes.get(i); 
يعطي  Execption : The operator + is undefined for the argument type(s) double, Note
بتاريخ:

جافا لا يمكنها جمع

Object ما لم يتم عمل cast لل object

 

لذلك

الخطأ ينص على أن لا يستطيع المترجم جمع متغير من نوع Note

 

ماذا يحتوي class Note ؟

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

السلام عليكم
محتوى الكلاسNote  هو

package Eleve;

public class Note {
    
    private String nom;
    private double note;
public Note(String nom, double note) {
  this.nom = nom;
    this.note = note;
     }
    public String getNom() {
        return nom;
    }
    public void setNom(String nom) {
        this.nom = nom;
    }
    public double getNote() {
        return note;
    }
    public void setNote(double note) {
        this.note = note;
    }
    public void afficher(){
        System.out.println("la note est : " +note );
    }
    
    
}
 

بتاريخ:

هي مشكلة في اختلاف نوع المتغير تحتاج casting

 

ممكن تجرب شيء كهذا

    public static double moyenne(ArrayList<Note> notes) {
        Object s = 0.0;
        Double d = 0.0;
        for (int i = 0; i <= notes.size(); i++) {
            s = notes.get(i);
            d = d + (Double) s;
        }
        return d / notes.size();

    }
بتاريخ:

تحتاج إلى كتابة الأمر هكذا

s = s + ((Note)notes.get(i)).getNote();
بتاريخ:
  • كاتب الموضوع

شكرا على المساعدة قد تم حل المشكل

بتاريخ:

العفو

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

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

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

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

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

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.