RiapaMeTpbi anrmeTa
Download 399.85 Kb.
|
Java (Laboratoriya)
StringBuffer sinfi uchun teng () va hashCode () usullari bekor qilinmaydi , ya'ni . ikkita ob'ektning mazmunini solishtirish mumkin emas va ushbu turdagi barcha ob'ektlarning xesh kodlari Ob'ekt sinfi bilan bir xil tarzda hisoblanadi .
/* № 7.8 misol: StringBuffer obyektlari va ularning xesh kodlarini solishtirish: EqualsStringBuffer . java */ public sinf EqualsStringBuffer { public static void main(String[] args) { StringBuffer sb1 = yangi StringBuffer("Quyosh"); StringBuffer sb2 = yangi StringBuffer("Quyosh"); System.out.print(sb1.equals(sb2)); System.out.print( sb 1.hashCode () == sb 2.hashCode ( ) ); } } ikki marta noto'g'ri bo'ladi .
Laboratoriya mashg'ulotining o'tkazish jarayoni
Download 399.85 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling