Tasodifiy sana qanday qilib lineer taqsimot bilan olinadi?

Qiymatlarning (teskari) chiziqli taqsimlanishidan tasodifiy millisekundning qiymatiga ega bo'lishni xohlayman (agar men termini olsam).

Aslida ikkita nuqta erta </​​code> va vaqt oralig'ida t ( Date erta </​​code> ga nisbatan t ning late ga nisbatan ancha katta ehtimollik mavjud bo'lgan kech/ . late ning o'zi 0.0 ehtimoliga ega bo'lishi mumkin.

Joriy java kodim faqat tekis taqsimlanishi dan foydalanadi, shuning uchun uni (teskari) chiziqli taqsimotga o'zgartirishni rejalashtiraman :

public Date getRandomDate(Date early, Date late) {
  long diff = late.getTime() - early.getTime();
  final int randVal = rand.nextInt((int) diff);
  Calendar cal = Calendar.getInstance();
  cal.setTime(early);
  cal.add(Calendar.MILLISECOND, randVal);
  return cal.getTime();
}
3
Bu muammoni hal qila oladimi:
qo'shib qo'ydi muallif GhostCat, manba
Siz nima so'rayotganingizga juda amin emasman. Tasodifiy sonlarni chiziqli taqsimlashni qanday qilib olish mumkin, yoki siz buni tarixga tatbiq qilishda muammolaringiz bormi?
qo'shib qo'ydi muallif Thomas, manba
Siz nima so'rayotganingizga juda amin emasman. Tasodifiy sonlarni chiziqli taqsimlashni qanday qilib olish mumkin, yoki siz buni tarixga tatbiq qilishda muammolaringiz bormi?
qo'shib qo'ydi muallif Thomas, manba
Va, albatta, siz faqat uzun dan Sana ni yaratishingiz mumkin. Taqvimdan foydalanishga hojat yo'q. kabi yangi sanasi (early.getTime() + randVal);
qo'shib qo'ydi muallif rustyx, manba
Va, albatta, siz faqat uzun dan Sana ni yaratishingiz mumkin. Taqvimdan foydalanishga hojat yo'q. kabi yangi sanasi (early.getTime() + randVal);
qo'shib qo'ydi muallif rustyx, manba

6 javoblar

shunga o'xshash savolga bu javob off Piggy-tisarila siz faqat ikki rand qo'ng'iroqlar kamida olishi mumkin:

final int randVal = Math.min(rand.nextInt((int) diff), rand.nextInt((int) diff));

Nihoyat, kümülatif tarqatish funktsiyasi yordamida ( x ^ 2 ):

int randVal = (int) Math.floor(diff * (1.0 - Math.sqrt(rand.nextDouble())));
if(randVal >= diff) randVal = 0;//handle the edge case

Sizning talablaringizni qondirish uchun, kvadrat ildiz 1,0dan distributsiyani almashtirishga olib keldi, ya'ni oraliqning pastki qismida katta zichlikni oshirdi.

3
qo'shib qo'ydi
min yaxshi bo'ldi. Men chiziqli emas, kvadratik bo'lishni xohlardim.
qo'shib qo'ydi muallif towi, manba
argh! Ha to'g'ri. lanet la'nat la'nati.
qo'shib qo'ydi muallif towi, manba
@towi - FYI, men boshqa yo'lni qo'shdim. tahrir qilish.
qo'shib qo'ydi muallif Patrick Parker, manba
@towi ishonadimi yoki yo'qmi, [0, 1] linear tarqatish uchun CDF x ^ 2 . Men taqdim etgan Vikipediya havolasini ko'ring. Yoki meni tekshirishni xohlasangiz matematik StackExchange-ni tekshiring. ;)
qo'shib qo'ydi muallif Patrick Parker, manba

shunga o'xshash savolga bu javob off Piggy-tisarila siz faqat ikki rand qo'ng'iroqlar kamida olishi mumkin:

final int randVal = Math.min(rand.nextInt((int) diff), rand.nextInt((int) diff));

Nihoyat, kümülatif tarqatish funktsiyasi yordamida ( x ^ 2 ):

int randVal = (int) Math.floor(diff * (1.0 - Math.sqrt(rand.nextDouble())));
if(randVal >= diff) randVal = 0;//handle the edge case

Sizning talablaringizni qondirish uchun, kvadrat ildiz 1,0dan distributsiyani almashtirishga olib keldi, ya'ni oraliqning pastki qismida katta zichlikni oshirdi.

3
qo'shib qo'ydi
argh! Ha to'g'ri. lanet la'nat la'nati.
qo'shib qo'ydi muallif towi, manba
min yaxshi bo'ldi. Men chiziqli emas, kvadratik bo'lishni xohlardim.
qo'shib qo'ydi muallif towi, manba
@towi - FYI, men boshqa yo'lni qo'shdim. tahrir qilish.
qo'shib qo'ydi muallif Patrick Parker, manba
@towi ishonadimi yoki yo'qmi, [0, 1] linear tarqatish uchun CDF x ^ 2 . Men taqdim etgan Vikipediya havolasini ko'ring. Yoki meni tekshirishni xohlasangiz matematik StackExchange-ni tekshiring. ;)
qo'shib qo'ydi muallif Patrick Parker, manba

Parker tomonidan qabul qilingan javoblar to'g'ri va yaxshi bajarilgan kabi ko'rinadi.

Java.time-dan foydalanish

Savol-da java.time kurslari tomonidan bekor qilingan eskirib qolgan eskirgan sana-vaqt mashg'ulotlarini ishlatadi. Parkerning echimi bilan bir qatorda java.time vaqtida qayta yozilgan.

Xabarnomalar

First, if you must work with java.util.Date objects, convert to/from Xabarnomalar . The Xabarnomalar class represents a moment on the timeline in UTC with a resolution of nanoseconds (up to nine (9) digits of a decimal fraction). To convert, look to new methods added to the old classes.

Instant instant = myJavaUtilDate.toInstant(); //From legacy to modern class.
java.util.Date myJavaUtilDate = java.util.Date.from( instant ) ; //From modern class to legacy.

Let's rewrite the method signature but passing and returning Xabarnomalar objects.

public Instant getRandomDate( Instant early , Instant late) {

early argumentini later argumentidan ancha oldinroq tasdiqlang. Shu bilan bir qatorda, quyida ko'rsatilgan Vaqt ning salbiy emasligini tasdiqlang (! Duration.isNegative() )).

    if( early.isAfter( late) ) { … } //Assert `early` is not after `late`.

Yarim ochiq

Calculate the delta between the earliest and latest moments. This is done in the Yarim ochiq approach often used to define spans of time, where the beginning is inclusive and the ending is exclusive.

Vaqt

The Vaqt class represents such a span in terms of a total number of seconds plus a fractional second in nanoseconds.

    Duration duration = Duration.between( early , late ) ;

Biz tasodifiy matematik qilish uchun biz bitta tamsayıni istaymiz. NanoSeconds rezolyutsiyasini boshqarish uchun bizga 64-bit uzun 32-bit int o'rniga emas.

ThreadLocalRandom

Tip: If generating these values across threads, use the class ThreadLocalRandom . To quote the doc:

Qabul qilingan bo'lsa, birgalikdagi dasturlarda birgalikda tasodifiy ob'ektlar o'rniga ThreadLocalRandomdan foydalanish, odatda juda kamroq yuk va tortishuvlarga duch keladi.

We can specify the range in Yarim ochiqed style with the origin being inclusive and the bound being exclusive by calling ThreadLocalRandom::nextLong( origin , bound ).

    long bound = duration.toNanos() ;
    long nanos1 = ThreadLocalRandom.current().nextLong( 0 , bound ); 
    long nanos2 = ThreadLocalRandom.current().nextLong( 0 , bound ); 
    long nanos = Math.min( nanos1 , nanos2 ); //Select the lesser number.
    Instant instant = early.plusNanos( nanos );
    return instant ;
}

Jonli misol

Ideone.com saytida jonli ishlashning pastki kodini ko'ring.

Biz har qanday tarix uchun ( LocalDate ) hosil qilingan sana-vaqt qiymatlari sonini oldingi sanaga nisbatan kerakli natijalarni tekshirish uchun natijalarni tekshirishning qulay usuli sifatida chiqaramiz.

The test harness shows you how to assign a time zone (ZoneId) to an Xabarnomalar to get a ZonedDateTime object, and from there extract a LocalDate. Use that as a guide if you wish to view the Xabarnomalar objects through the lens of some particular region’s wall-clock time rather than in UTC.

/* package whatever;//don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

import java.util.concurrent.ThreadLocalRandom ;
import java.util.TreeMap ;

import java.time.*;
import java.time.format.*;
import java.time.temporal.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        Ideone app = new Ideone();
        app.doIt();
    }

    public void doIt() {
        ZoneId z = ZoneId.of( "America/Montreal" ) ;
        int count = 10 ;
        LocalDate today = LocalDate.now( z );
        LocalDate laterDate = today.plusDays( count );
        Instant start = today.atStartOfDay( z ).toInstant();
        Instant stop = laterDate.atStartOfDay( z ).toInstant();

       //Collect the frequency of each date. We want to see bias towards earlier dates.
        List dates = new ArrayList<>( count );
        Map map = new TreeMap();
        for( int i = 0 ; i <= count ; i ++ ) {
            LocalDate localDate = today.plusDays( i ) ; 
            dates.add( localDate ); //Increment to next date and remember.
            map.put( localDate , new Integer( 0 ) );//Prepopulate the map with all dates.
        }
        for( int i = 1 ; i <= 10_000 ; i ++ ) {
            Instant instant = this.getRandomInstantBetween( start , stop );
            LocalDate localDate = instant.atZone( z ).toLocalDate();
            Integer integer = map.get( localDate );
            map.put( localDate , integer +  1); //Increment to count each time get a hit on this date.
        }
        System.out.println( map );
    }

    public Instant getRandomInstantBetween( Instant early , Instant late) {

        Duration duration = Duration.between( early , late ) ;
       //Assert the duration is positive or zero: ( ! duration.isNegative() )

        long bound = duration.toNanos() ;
        ThreadLocalRandom random = ThreadLocalRandom.current() ;
        long nanos1 = random.nextLong( 0 , bound );//Zero means the `early` date is inclusive, while `bound` here is exclusive.
        long nanos2 = random.nextLong( 0 , bound ); 
        long nanos = Math.min( nanos1 , nanos2 ); //Select the lesser number.
        Instant instant = early.plusNanos( nanos );

        return instant;
    }
}

Mana bir natija natijalari. Ular menga yaxshi qarashadi, lekin men statistikist emasman. O'zingizning xavf-xataringizdan foydalaning.

{2017-02-24 = 1853, 2017-02-25 = 1697, 2017-02-26 = 1548, 2017-02-27 = 1255, 2017-02-28 = 1130, 2017-03-01 = 926, 2017-03-02 = 706, 2017-03-03 = 485, 2017-03-04 = 299, 2017-03-05 = 101, 2017-03-06 = 0}

     

{2017-02-25 = 930, 2017-02-26 = 799, 2017-02-27 = 760, 2017-02-28 = 657, 2017-03-01 = 589, 2017-03-02 = 470, 2017-03-03 = 342, 2017-03-04 = 241, 2017-03-05 = 163, 2017-03-06 = 49, 2017-03-07 = 0)

     

{2017-02-25 = 878, 2017-02-26 = 875, 2017-02-27 = 786, 2017-02-28 = 676, 2017-03-01 = 558, 2017-03-02 = 440, 2017-03-03 = 370, 2017-03-04 = 236, 2017-03-05 = 140, 2017-03-06 = 41, 2017-03-07 = 0)


Java.time haqida

The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date, Calendar, & SimpleDateFormat.

Joda-Time loyihasi. wikipedia.org/wiki/Maintenance_mode "rel =" nofollow noreferrer "> parvarishlash rejimi , java.time darslari.

Ko'proq ma'lumot olish uchun Oracle o'rgatuvchi ni ko'ring. Va ko'plab misollar va tushuntirishlar uchun Stack Overflow ni qidiring. Shartnoma JSR 310 .

Java.time kurslarini qaerdan olish mumkin?

ThreeTen-Extra loyihasi java.timeni qo'shimcha darslar bilan kengaytirmoqda. Ushbu loyiha java.time uchun bo'lajak qo'shimchalar uchun dalil hisoblanadi. Bu yerda ba'zi foydali darslarni topishingiz mumkin: Interval , Yil hafta () , < kodi> YearQuarter , andfz ko'proq ma'lumot .

1
qo'shib qo'ydi
@towi Ha, sana-da buzilish. Barcha axborot texnologiyalari sanoati ushbu muhim mavzuni o'nlab yillar mobaynida e'tibordan chetda qoldirmadi. Joda-Time & java.time - bu mavzuni muhokama qilish uchun men bilgan birinchi jiddiy tashabbus bu keng qamrovli. Hozirda Java-da o'rnatilgan vaqt, Joda-Vaqtni ishlatish to'xtatiladi. Darhaqiqat, Java'dagi eski tarixiy darslar ko'p yillar davomida biz bilan bo'ladi. Java-ga o'tish uchun eski mashg'ulotlar uchun qo'shilgan yangi usullardan foydalanishni maslahat beraman. Java mazmunini va ma'lumotlarni saqlash va ma'lumotlar almashinuvini java.time vaqtida bajaring. Zarur bo'lgan joyga qayta aylantiring.
qo'shib qo'ydi muallif Basil Bourque, manba
@towi Zawinski saytiga tashrif buyurib nima demoqchisiz? Agar java.time sifat yoki ishonchliligi haqida xavotirda bo'lsangiz, iltimos. Java.time kurslari Stiven Colebourne boshchiligidagi "jodastephen" boshchiligidagi odamlar tomonidan yaratilgan bo'lib, u ko'p yillar davomida ajoyib Joda-Time kutubxonasining rivojlanishiga aylandi. U erda o'rganilgan narsalarni olib, java.time yaratish uchun qayta ishlab chiqilgan. Endi java.time Java-ning ichki qismi va Java-versiyasi bilan ketadigan keng ko'lamli testdir. Men bilganimning faqatgina xatoliklari burchaklarni ajratishda burchak urishgan.
qo'shib qo'ydi muallif Basil Bourque, manba
Men bilaman, lekin etarli darajada keng tarqalmagan Java java kurslariga kirish uchun tashakkur. Ehtimol, sizning xabaringiz buni tuzatishga yordam beradi. Faqatgina Zawinski "hozirda bizda yana bir muammo bor" deb qo'rqishadi, .
qo'shib qo'ydi muallif towi, manba
Yo'q, sifatni tashvishga solmayman. Men juda ko'p sana/vaqt-APIlar haqida qayg'uraman; bu shoshqaloqlik. Va har doim siz turli xil ma'lumotlar/vaqt API-larini talab qiladigan uchinchi tomon-libslarga ega bo'lasiz. Shunday qilib, siz doimo oldinga va orqaga aylanasiz. Buning sababi, eski API'lar hech qachon yo'qolmaydi. Men har kuni Sana , Taqvim , XMLGrCal , o'zim WDate va ba'zan Jodatime . 5 * 4 = 20 mumkin bo'lgan API-o'zgarish allaqachon. Endi 6 * 5 = 30 bo'ladi. Menga noto'g'ri tushunmang, men turli xil Sana/Vaqt-API-larga bo'lgan ehtiyojni ko'rib chiqaman. Menga oddiygina emas, oddiygina edi.
qo'shib qo'ydi muallif towi, manba

Parker tomonidan qabul qilingan javoblar to'g'ri va yaxshi bajarilgan kabi ko'rinadi.

Java.time-dan foydalanish

Savol-da java.time kurslari tomonidan bekor qilingan eskirib qolgan eskirgan sana-vaqt mashg'ulotlarini ishlatadi. Parkerning echimi bilan bir qatorda java.time vaqtida qayta yozilgan.

Xabarnomalar

First, if you must work with java.util.Date objects, convert to/from Xabarnomalar . The Xabarnomalar class represents a moment on the timeline in UTC with a resolution of nanoseconds (up to nine (9) digits of a decimal fraction). To convert, look to new methods added to the old classes.

Instant instant = myJavaUtilDate.toInstant(); //From legacy to modern class.
java.util.Date myJavaUtilDate = java.util.Date.from( instant ) ; //From modern class to legacy.

Let's rewrite the method signature but passing and returning Xabarnomalar objects.

public Instant getRandomDate( Instant early , Instant late) {

early argumentini later argumentidan ancha oldinroq tasdiqlang. Shu bilan bir qatorda, quyida ko'rsatilgan Vaqt ning salbiy emasligini tasdiqlang (! Duration.isNegative() )).

    if( early.isAfter( late) ) { … } //Assert `early` is not after `late`.

Yarim ochiq

Calculate the delta between the earliest and latest moments. This is done in the Yarim ochiq approach often used to define spans of time, where the beginning is inclusive and the ending is exclusive.

Vaqt

The Vaqt class represents such a span in terms of a total number of seconds plus a fractional second in nanoseconds.

    Duration duration = Duration.between( early , late ) ;

Biz tasodifiy matematik qilish uchun biz bitta tamsayıni istaymiz. NanoSeconds rezolyutsiyasini boshqarish uchun bizga 64-bit uzun 32-bit int o'rniga emas.

ThreadLocalRandom

Tip: If generating these values across threads, use the class ThreadLocalRandom . To quote the doc:

Qabul qilingan bo'lsa, birgalikdagi dasturlarda birgalikda tasodifiy ob'ektlar o'rniga ThreadLocalRandomdan foydalanish, odatda juda kamroq yuk va tortishuvlarga duch keladi.

We can specify the range in Yarim ochiqed style with the origin being inclusive and the bound being exclusive by calling ThreadLocalRandom::nextLong( origin , bound ).

    long bound = duration.toNanos() ;
    long nanos1 = ThreadLocalRandom.current().nextLong( 0 , bound ); 
    long nanos2 = ThreadLocalRandom.current().nextLong( 0 , bound ); 
    long nanos = Math.min( nanos1 , nanos2 ); //Select the lesser number.
    Instant instant = early.plusNanos( nanos );
    return instant ;
}

Jonli misol

Ideone.com saytida jonli ishlashning pastki kodini ko'ring.

Biz har qanday tarix uchun ( LocalDate ) hosil qilingan sana-vaqt qiymatlari sonini oldingi sanaga nisbatan kerakli natijalarni tekshirish uchun natijalarni tekshirishning qulay usuli sifatida chiqaramiz.

The test harness shows you how to assign a time zone (ZoneId) to an Xabarnomalar to get a ZonedDateTime object, and from there extract a LocalDate. Use that as a guide if you wish to view the Xabarnomalar objects through the lens of some particular region’s wall-clock time rather than in UTC.

/* package whatever;//don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

import java.util.concurrent.ThreadLocalRandom ;
import java.util.TreeMap ;

import java.time.*;
import java.time.format.*;
import java.time.temporal.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        Ideone app = new Ideone();
        app.doIt();
    }

    public void doIt() {
        ZoneId z = ZoneId.of( "America/Montreal" ) ;
        int count = 10 ;
        LocalDate today = LocalDate.now( z );
        LocalDate laterDate = today.plusDays( count );
        Instant start = today.atStartOfDay( z ).toInstant();
        Instant stop = laterDate.atStartOfDay( z ).toInstant();

       //Collect the frequency of each date. We want to see bias towards earlier dates.
        List dates = new ArrayList<>( count );
        Map map = new TreeMap();
        for( int i = 0 ; i <= count ; i ++ ) {
            LocalDate localDate = today.plusDays( i ) ; 
            dates.add( localDate ); //Increment to next date and remember.
            map.put( localDate , new Integer( 0 ) );//Prepopulate the map with all dates.
        }
        for( int i = 1 ; i <= 10_000 ; i ++ ) {
            Instant instant = this.getRandomInstantBetween( start , stop );
            LocalDate localDate = instant.atZone( z ).toLocalDate();
            Integer integer = map.get( localDate );
            map.put( localDate , integer +  1); //Increment to count each time get a hit on this date.
        }
        System.out.println( map );
    }

    public Instant getRandomInstantBetween( Instant early , Instant late) {

        Duration duration = Duration.between( early , late ) ;
       //Assert the duration is positive or zero: ( ! duration.isNegative() )

        long bound = duration.toNanos() ;
        ThreadLocalRandom random = ThreadLocalRandom.current() ;
        long nanos1 = random.nextLong( 0 , bound );//Zero means the `early` date is inclusive, while `bound` here is exclusive.
        long nanos2 = random.nextLong( 0 , bound ); 
        long nanos = Math.min( nanos1 , nanos2 ); //Select the lesser number.
        Instant instant = early.plusNanos( nanos );

        return instant;
    }
}

Mana bir natija natijalari. Ular menga yaxshi qarashadi, lekin men statistikist emasman. O'zingizning xavf-xataringizdan foydalaning.

{2017-02-24 = 1853, 2017-02-25 = 1697, 2017-02-26 = 1548, 2017-02-27 = 1255, 2017-02-28 = 1130, 2017-03-01 = 926, 2017-03-02 = 706, 2017-03-03 = 485, 2017-03-04 = 299, 2017-03-05 = 101, 2017-03-06 = 0}

     

{2017-02-25 = 930, 2017-02-26 = 799, 2017-02-27 = 760, 2017-02-28 = 657, 2017-03-01 = 589, 2017-03-02 = 470, 2017-03-03 = 342, 2017-03-04 = 241, 2017-03-05 = 163, 2017-03-06 = 49, 2017-03-07 = 0)

     

{2017-02-25 = 878, 2017-02-26 = 875, 2017-02-27 = 786, 2017-02-28 = 676, 2017-03-01 = 558, 2017-03-02 = 440, 2017-03-03 = 370, 2017-03-04 = 236, 2017-03-05 = 140, 2017-03-06 = 41, 2017-03-07 = 0)


Java.time haqida

The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date, Calendar, & SimpleDateFormat.

Joda-Time loyihasi. wikipedia.org/wiki/Maintenance_mode "rel =" nofollow noreferrer "> parvarishlash rejimi , java.time darslari.

Ko'proq ma'lumot olish uchun Oracle o'rgatuvchi ni ko'ring. Va ko'plab misollar va tushuntirishlar uchun Stack Overflow ni qidiring. Shartnoma JSR 310 .

Java.time kurslarini qaerdan olish mumkin?

ThreeTen-Extra loyihasi java.timeni qo'shimcha darslar bilan kengaytirmoqda. Ushbu loyiha java.time uchun bo'lajak qo'shimchalar uchun dalil hisoblanadi. Bu yerda ba'zi foydali darslarni topishingiz mumkin: Interval , Yil hafta () , < kodi> YearQuarter , andfz ko'proq ma'lumot .

1
qo'shib qo'ydi
@towi Ha, sana-da buzilish. Barcha axborot texnologiyalari sanoati ushbu muhim mavzuni o'nlab yillar mobaynida e'tibordan chetda qoldirmadi. Joda-Time & java.time - bu mavzuni muhokama qilish uchun men bilgan birinchi jiddiy tashabbus bu keng qamrovli. Hozirda Java-da o'rnatilgan vaqt, Joda-Vaqtni ishlatish to'xtatiladi. Darhaqiqat, Java'dagi eski tarixiy darslar ko'p yillar davomida biz bilan bo'ladi. Java-ga o'tish uchun eski mashg'ulotlar uchun qo'shilgan yangi usullardan foydalanishni maslahat beraman. Java mazmunini va ma'lumotlarni saqlash va ma'lumotlar almashinuvini java.time vaqtida bajaring. Zarur bo'lgan joyga qayta aylantiring.
qo'shib qo'ydi muallif Basil Bourque, manba
@towi Zawinski saytiga tashrif buyurib nima demoqchisiz? Agar java.time sifat yoki ishonchliligi haqida xavotirda bo'lsangiz, iltimos. Java.time kurslari Stiven Colebourne boshchiligidagi "jodastephen" boshchiligidagi odamlar tomonidan yaratilgan bo'lib, u ko'p yillar davomida ajoyib Joda-Time kutubxonasining rivojlanishiga aylandi. U erda o'rganilgan narsalarni olib, java.time yaratish uchun qayta ishlab chiqilgan. Endi java.time Java-ning ichki qismi va Java-versiyasi bilan ketadigan keng ko'lamli testdir. Men bilganimning faqatgina xatoliklari burchaklarni ajratishda burchak urishgan.
qo'shib qo'ydi muallif Basil Bourque, manba
Men bilaman, lekin etarli darajada keng tarqalmagan Java java kurslariga kirish uchun tashakkur. Ehtimol, sizning xabaringiz buni tuzatishga yordam beradi. Faqatgina Zawinski "hozirda bizda yana bir muammo bor" deb qo'rqishadi, .
qo'shib qo'ydi muallif towi, manba
Yo'q, sifatni tashvishga solmayman. Men juda ko'p sana/vaqt-APIlar haqida qayg'uraman; bu shoshqaloqlik. Va har doim siz turli xil ma'lumotlar/vaqt API-larini talab qiladigan uchinchi tomon-libslarga ega bo'lasiz. Shunday qilib, siz doimo oldinga va orqaga aylanasiz. Buning sababi, eski API'lar hech qachon yo'qolmaydi. Men har kuni Sana , Taqvim , XMLGrCal , o'zim WDate va ba'zan Jodatime . 5 * 4 = 20 mumkin bo'lgan API-o'zgarish allaqachon. Endi 6 * 5 = 30 bo'ladi. Menga noto'g'ri tushunmang, men turli xil Sana/Vaqt-API-larga bo'lgan ehtiyojni ko'rib chiqaman. Menga oddiygina emas, oddiygina edi.
qo'shib qo'ydi muallif towi, manba

Ehtimol, ushbu javobda ko'rsatilgandek, Sana o'xshashligini qo'llashingiz mumkin.

Java: tasodifiy tamsayı, bir xil bo'lmagan taqsimot bilan

0
qo'shib qo'ydi

Ehtimol, ushbu javobda ko'rsatilgandek, Sana o'xshashligini qo'llashingiz mumkin.

Java: tasodifiy tamsayı, bir xil bo'lmagan taqsimot bilan

0
qo'shib qo'ydi