Comment on page
🤯
İleri Seviye
İlgilenenlere biraz daha ileri seviye notlar
Modüller tek bir iş için yapılandırılmış projelerdir.
- Büyük projeler birdenn fazla modülden oluşur
- Her modül diğerlerinden bağımsız olarak işler
- Java 9 ve sonrasında gelen bir sistemdir
Java modül yapısı olanmodule-info.java
dosyasını kullandığımızdasrc
dizini sources özelliğine sahip olmazsajava.datatransfer
ilejava.desktop
modülleri içerisindekijava.awt
'ler çakışmakta ve hata vermekte 😢 (module yapısı)
module ModulIsmı {
// Projeye dahil edilenler
requires javafx.fxml;
requires javafx.controls;
requires java.datatransfer;
requires java.desktop;
requires com.jfoenix;
requires com.gluonhq.charm.glisten;
// API isteklerini yardımcı araç ile açma @FMXL vs gibi
opens com.yedhrab.controllers to javafx.fxml;
// Dışa aktarılacak erişebilir class'lar (genelde Main)
exports com.yedhrab.ytoolsfx.application.MainApp;
}
for (Thread t : Thread.getAllStackTraces().keySet()){
if (t.getState()==Thread.State.RUNNABLE)
t.interrupt();
}
Generic yapısı tipi belirsiz objeler için kullanılır.
<T>
ile tanımlanır gösterilir,T
ile kullanlırT
, Herhangi bir harf
- Int için
T = int
, string içinT = String
olarak işlem görür <T>
deyimi her alanda kullanılabilirT[]
dizi,ArrayList<T>
dizi listesi vs..
The most commonly used type parameter names are:
E - Element (used extensively by the Java Collections Framework)
K - Key
N - Number
T - Type
V - Value
S,U,V etc. - 2nd, 3rd, 4th types
public static <T> T[] print(T rastgele) {
System.out.println(rastgele)
return rasgele;
}
public static <E> void printArray( E[] inputArray ) {
// Display array elements
for(E element : inputArray) {
System.out.printf("%s ", element);
}
System.out.println();
}
public static <T> T[] mergeArray(T[]... arrays) {
int totalLen = 0;
for (T[] arr: arrays) {
totalLen += arr.length;
}
@SuppressWarnings("unchecked") T[] all = (T[])Array.newInstance(
arrays.getClass().getComponentType().getComponentType(), totalLen);
int copied = 0;
for (T[] arr: arrays) {
System.arraycopy(arr, 0, all, copied, arr.length);
copied += arr.length;
}
return all;
}
void openInDefaultBrowser(String url) throws URISyntaxException, IOException {
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(new URI(url));
}
}
Process process = Runtime.getRuntime().exec(command);
// JDK 12
Process pb = new ProcessBuilder("myCommand", "myArg1", "myArg2").start();
Process pb = new ProcessBuilder(<string[]>).start();
Runtime rt = Runtime.getRuntime();
String[] commands = {"system.exe", "-get t"};
Process proc = rt.exec(commands);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(proc.getErrorStream()));
// Read the output from the command
System.out.println("Here is the standard output of the command:\n");
String s = null;
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
// Read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}
Settings
Build, Execution, Development
Compiler
Java Compiler
Project Byte Code Version
****veTarget Byte Code Version
alanlarını12
yapın
Last modified 1mo ago