Number bir neche formada gele biler bize. Meselen, 99451xxxxxxx 99455xxxxxxx ve s. 051xxxxxxx 055xxxxxxx ve s. 51xxxxxxx 55xxxxxxx ve s. Bu nomreleri standart formaya salmaq uchun kichik kod : public static String validate (String number){ final String prefix = "994" ; if (number.length() == 12 && number.matches( "^(994)+(50|51|55|70|77|99).*$" )) { return number ; } else if (number.length() == 10 && number.matches( "^(0)+(50|51|55|70|77|99).*$" )) { return prefix + number.substring( 1 ) ; } else if (number.length() == 9 && number.matches( "^(50|51|55|70|77|99).*$" )) { return prefix + number ; } return null; } sonda bize qayidan netice 99451xxxxxxx ve ya 99455xxxxxxx sheklinde olacaq. Eger null qayidarsa, bu methodun cagrildigi yerde uygun helli etmek olar.
Ilk once proqrami run etmezden qabaq, qarshimizda olan ClassName.java faylini nezerden kecirek. Bu fayl sadece bildiyimiz .txt faylindan ibaretdir. Burada her hansi bir IDE vasitesile proqrami run etdikde, hemin IDE, JDK nin terkibindeki bin package in icindeki javac ni cagirir. javac bizim yazdigimiz ClassName.java faylini bytecodelara cevirir, ve eyni adli .class fayli yaradir. Bu fayl JRE uchun lazimlidir. JRE oz novbesinde elde etdiyi .class formatli fayllardan istifade ederek, OS a davamli olaraq emrler gonderir ve proqrami icra edir. QEYD: JDK , terkibinde compiler ve run etmek uchun istifade olunan komponentleri ozunde saxlayir. Java Development Kit . Proqramcinin ehtiyac duydugu komponentdir. JRE , java da yazilmish proqrami istenilen OS da run etmek uchun, qisaca proqrami run etmek uchun istifade olunur. Java Runtime Environment. yazdigimiz java app i run etmek uchun teleb olunan minimum komponent jre dir. user teref uchun esasen ehtiyac duyulur https://medium.com/@b...
Tutaq ki, ashagidaki formada bir class yaratmishiq : public class User { public String name ; public String username ; public int age ; public static String test ; public void foo (){} public static void foo2 (){} } application u run etdikde, javac .java fayllarini compile edib .class bytecodelarini yaratdiqdan sonra java, yeni JVM ishe dushur. Yalniz ehtiyaci oldugu classlari yaddasha yukleyir. Meselen, main methodunda, User classinin static metodunu cagiraq, bu zaman class load olunacaq ve ya class a ehtiyac duyulan diger hallarda. Eger kod hemin class a ehtiyac duymasa, bu class yaddasha yuklenmir. JVM yaddash da yer ayiran vaxti static acar sozu olanlari da class terkibinde saxladir. Yeni yaddash da onlar uchun de ayrica yer ayirir. Static - yeni stabil kimi de basha dushule biler. Bu classi i istifade etmek isteyende, yeni User. yazib classin icinde olan deyishen ve metodlara chatmaq isteyende yalniz static olanlar gorsen...
Comments
Post a Comment