Синглтон в Java: https://habr.com/post/27108/
Getting started:
Related tutorials:
A little lookup for commands I use frequently
- Commit all edited files and add a message
git commit -a -m "My commit"
- Add all new files
git add .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class InetWork { | |
public static void saveToFile(String address, File folder) { | |
try { | |
URL url = new URL(address); //установка соединения | |
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); //возможность доступа | |
InputStream is = connection.getInputStream(); //поток | |
int n = address.lastIndexOf("/"); //после последнего слеша будет имя файла | |
String fileName = address.substring(n + 1); //записываем сюда имя файла | |
File file = new File(folder, fileName); //сохраняем в каталоге фолдер с именем файлНейм | |
OutputStream os = new FileOutputStream(file); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FindFactorial { | |
public static void main(String[] args) { | |
System.out.println(factorial(5)); | |
} | |
private static int factorial(int x){ | |
return (x == 1 ? 1 : x*factorial(x-1)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PrintfExample { | |
public static void main(String[] args) { | |
int a = 5; | |
String b = "five"; | |
System.out.printf("A equals %d, and B equals %s", a , b); | |
} | |
} |
NewerOlder