Чашечка Java
رفتن به کانال در Telegram
Лучшие материалы по Java на русском и английском Разместить рекламу: @tproger_sales_bot Правила общения: https://tprg.ru/rules Другие каналы: @tproger_channels
نمایش بیشتر8 540
مشترکین
-324 ساعت
-127 روز
-2930 روز
آرشیو پست ها
8 539
Coursera Certification Review - Is Data Science Specialization from John Hopkins worth it in 2022?
Hello guys, if you are thinking of joining Data Science Specialization at John Hopkins University in Coursera but thinking about whether it's worth your time and money or not, then you have come...
Read: http://www.java67.com/2020/10/data-science-specialization-by-johns-hopkins-coursera-review.html
8 539
Top 5 Free Courses to Crack AWS SysOps Administration Associate Certification Exam in 2022 - Best of Lot
Hello guys, if you are preparing for the AWS SysOps Administrator Associate certification exam and looking for free online courses then you have come to the right place. You might have heard about...
Read: http://www.java67.com/2020/08/top-5-free-courses-to-pass-aws-sysops-administrator-associate-exam.html
8 539
Top 6 Free Web Design Online Courses for Beginners in 2022 - Best of Lot
Hello guys, if you want to become a web designer and look for free online courses to learn web design in 2022, you have come to the right place. In the past, I have shared the best free online...
Read: http://www.java67.com/2020/07/top-5-free-courses-to-become-web-design.html
8 539
5 Best Free Courses to learn Machine Learning and Deep Learning in 2022 - Best of Lot
Hello guys, if you want to learn Machine learning and Deep learning in 2022 and look for the best online courses and tutorials, you have come to the right place. In this article, I will share some of...
Read: http://www.java67.com/2019/01/5-free-courses-to-learn-machine-and-deep-learning-in-2019.html
8 539
5 Free Courses to learn Django for Beginners in 2022- Best of Lot
Hello guys, if you want to learn Django and looking for some free online Django courses to start with, then you have come to the right place. In the past, I have shared the best Python courses and...
Read: http://www.java67.com/2020/08/5-free-courses-to-learn-django-by-building-projects.html
8 539
Top 6 Courses to learn React Hooks Online in 2022 - Best of Lot
Hello guys, if you want to learn React hooks and looking for the best React hooks courses then you cha come to the right place. Earlier, I have shared free React courses, books, and websites to learn...
Read: http://www.java67.com/2021/11/top-6-courses-to-learn-react-hooks.html
8 539
Туториал по JUnit 5 - Аннотация @AfterEach
Аннотация @AfterEach используется для обозначения того, что аннотированный метод должен выполняться после каждого метода в текущем классе.
@Test @RepeatedTest, @ParameterizedTest, or @TestFactory
Аннотация JUnit 5 @AfterEach является заменой @Afterаннотации в JUnit 4.
По умолчанию тестовые методы будут выполняться в том же потоке, что и @AfterEachаннотированный метод.
Читать: https://habr.com/ru/post/590757/?utm_campaign=5907578 539
Туториал по JUnit 5 - Аннотация @BeforeEach
Это продолжение туториала по JUnit 5. Введение опубликовано здесь.
Аннотация
@BeforeEachиспользуется для обозначения того, что аннотированный метод должен выполняться перед каждым методом @Test, @RepeatedTest, @ParameterizedTest,или@TestFactory в текущем классе.
Аннотация JUnit 5 @BeforeEach является одним из методов жизненного цикла и заменяет аннотацию @Beforeв JUnit 4.
Читать: https://habr.com/ru/post/590741/?utm_campaign=5907418 539
Java News Roundup: OpenJDK JEPs for JDK 18, Spring Updates, Payara Platform, Kotlin 1.6
This week's Java roundup for November 15th, 2021 features news from OpenJDK JEPs, JDK 18, Project Loom, numerous point releases on Spring projects, MicroProfile 5.0-RC2, Payara Platform, a proposed new Jakarta EE specification, JHipster 7.4.0, TornadoVM 0.12, Apache Camel K 1.7 and Kotlin 1.6.0.
By Michael Redlich
Read: https://www.infoq.com/news/2021/11/java-news-roundup-nov15-2021/
8 539
Туториал по JUnit 5 - Аннотация @BeforeAll
Аннотация JUnit 5 @BeforeAll обозначает метод, который является методом жизненного цикла.
@BeforeAllэто замена @BeforeClassаннотации в JUnit 4.
Читать: https://habr.com/ru/post/590715/?utm_campaign=5907158 539
10 ways to Learn New Programming language or Tech skills in 2022?
One of the main challenges of being a programmer or software engineer is constant learning. Yes, that's true. As a programmer or developers, we always need to learn new things, sometimes every...
Read: http://www.java67.com/2017/12/10-ways-to-learn-new-technology-programming-language-or-framework.html
8 539
Как внедрить Contract-First OpenAPI и как устроен центр авторизаций
Переходим к докладам по backend с IT-конференции ЮMoneyDay.
Первый кейс о том, как мы внедряли Contract-First. Описали процесс перехода от Сode-First к написанию OpenAPI-спецификаций и генерации кода по ним.
Во втором кейсе разбираем анатомию центра авторизаций. Рассказали, как организовать разработку и поддержку множества критичных процессов и спокойно спать по ночам.
Смотреть доклады по backend
Читать: https://habr.com/ru/post/590743/?utm_campaign=590743
8 539
Spring Cloud Config — обновление конфигурации
Spring Cloud Config позволяет хранить настройки конфигурации сервисов в git-репозитории и управлять настройками централизованно.
В этой статье поговорим об обновлении параметров, получаемых с сервера конфигурации.
Читать: https://habr.com/ru/post/590761/?utm_campaign=590761
8 539
Туториал по JUnit 5 - Жизненный цикл JUnit 5 теста
В JUnit 5 жизненный цикл теста управляется четырьмя основными аннотациями, то есть @BeforeAll, @BeforeEach, @AfterEach и @AfterAll. Вместе с тем, каждый тестовый метод должен быть помечен аннотацией
@Testиз пакета org.junit.jupiter.api.
Читать: https://habr.com/ru/post/590699/?utm_campaign=5906998 539
nown as a mantissa and after e is known as an exponent.
3. Single Character Constants
These constants can contain only a single character in single quotes. The single character is basically a character data type available in java.
Example: The ‘5’, ‘a’, ‘45’ are valid single character constants whereas ‘ab’, ‘f5’, name are invalid single character constants.
4. String Constants
String constants contain an order of characters enclosed in starting and ending double-quotes. Characters can include numbers, special characters, spaces, and alphabets.
Example: The “String”, “.. ”, “456 ” are valid string constants.
5. Backslash Character Constants
There are some specific backslash character constants defined in java. Like ‘\t’ is known as a horizontal tab and it can be used to provide spaces at the output. Some more backslash character constants are ‘\n’, ‘\f’, ‘\b’.
This was all about constants and their types. I hope your understanding of constants has increased after this blog. If you still have any question’s you can ask them in the comments.
Read: Types of Constants in Java.
8 539
Types of Constants in Java
Whenever we declare a constant in java its value tends to be the same throughout the entire program. In the case of a normal variable, we can change the assigned value. Java doesn’t allow the use of constants directly so we use static and final non-access modifiers.
The main motive of using constants is to decrease repeatability in the code with some standard values. It is cached by the Java Virtual Machine and written code results in improvement of the performance.
Let’s see the below example for declaring constant with the final keyword:
import java.util.*;
public class constants {
public static void main(String[] args) {
final int mod=1000000007;
System.out.println(mod);
}
}
In the above code, we have declared a variable mod having 1000000007 as a value inside it. We have written “final” at the starting of the code stating that this cannot be changed at any point inside the code. You can take the value of constant as an input from the user too as it is not compulsory to assign values during declaration.
If we try to change the value of a final variable then the compiler will show an error in compile time and run time as well. Let’s see the below example.
import java.util.*;
public class constants {
public static void main(String[] args) {
final int mod=1000000007;
mod =mod+5;
System.out.println(mod);
}
}
Output:
Exception in thread “main” java.lang.Error: Unresolved compilation problem:
The final local variable mod cannot be assigned. It must be blank and not using a compound assignment
at constants.main(constants.java:6)
Declaring Constant Outside Main Method
import java.util.*;
public class constants {
static final int standard_temp=37;
public static void main(String[] args) {
System.out.println(standard_temp);
}
}
In the above code, static keyword is used while declaring the standard_temp variable so that it can be called inside the main method.
So these were some of the ways to declare constants. I hope you have understood all of them. Now let’s see the types of constants.
Types of Constants in Java
Mainly there are two types of constants in java i.e, Numeric constant and Character constant but they have further types which we will be seeing below:
1. Integer Constants
These constants contain an order of digits that can either be positive or negative in nature. They are further divided into decimal integer constants, octal integer constants, and Hexadecimal constants.
Decimal Integer
It is an order of integers starting from 0 till 9, and they can be either negative or positive. It’s up to you to specify the plus sign or not as it is optional.
Example: The 55, -44, +546 numbers are valid whereas numbers like 11.01, 45 56, @12 are not valid because they either include some special characters, space, or decimal.
Octal Integer
Octal means 8 therefore it is an order of integers starting from 0 till 7, but it always starts from 0. So you need to remember that 8 & 9 cannot be written in the octal representation of any number.
Example: The 033, 0,0111 numbers are valid.
Hexadecimal Integer
These constants can contain digits from 0 to 9, and also alphabets starting from a to f both in small as well as in the capital. They always start either from 0x or 0X.
Example: The 0x22, 0xA2, 0X2B numbers are valid.
2. Real Constants
These constants contain fractional numbers in them. Real constants must have decimal values and they can either be negative or positive. Each real constant can be expressed as exponents also.
Example: The 23.5, 45.6756e2 numbers are valid. In 45.6745e2, the number before e is k[...]
8 539
5. Exit");
System.out.println("Please write an option: ");
option=sc.nextInt();
switch(option) {
case(1):
System.out.println("Please Enter the value to add: ");
int temp=sc.nextInt();
myset.add(temp);
break;
case(2):
System.out.println("Please Enter the value you want to remove ");
int ind=sc.nextInt();
myset.remove(ind);
break;
case(3):
System.out.println("The size of sett is: "+myset.size());
break;
case(4):
System.out.println("The elements of the set are: "+myset);
break;
case(5):
break;
}
}while(option!=5);
}
}
This was brief information about the collection hierarchy in Java. Comment down below if you have any queries.
Read: Java Collection Hierarchy.
8 539
s: "+myvec.size());
break;
case(4):
System.out.println("Enter the index: ");
int index=sc.nextInt();
System.out.println("The value is: "+ myvec.get(index));
break;
case(5):
System.out.println("The vector is as follows: "+myvec);
break;
case(6):
break;
}
}while(option!=6);
}
}
Stack
Stack arranges the values by the last in the first out (LIFO) method. We can add elements by the push method and remove them by the pop method. The way of creating a stack is as follows.
import java.util.*;
public class stackfunctions {
public static void main(String[] args) {
Stack<integer mystk=new Stack();
Scanner sc=new Scanner(System.in);
int option;
do{
System.out.println("1. Enter a new integer value to add in the stack");
System.out.println("2. Removing the item at the top of the stack");
System.out.println("3. Find the size of the stack");
System.out.println("4. Printing the whole stack");
System.out.println("5. Exit");
System.out.println("Please write an option: ");
option=sc.nextInt();
switch(option) {
case(1):
System.out.println("Please Enter the value to add: ");
int temp=sc.nextInt();
mystk.push(temp);
break;
case(2):
int t=mystk.pop();
System.out.println("The value "+t+" has been removed successfully from the stack.");
break;
case(3):
System.out.println("The size of Stack is: "+mystk.size());
break;
case(4):
System.out.println("The stack is as follows: "+mystk);
break;
case(5):
break;
}
}while(option!=5);
}
}
2. Queue
It contains the objects in a specific order in which they are added to the queue. If the queue is empty initially and we add a value then it will be at the starting of the queue as long as the queue exists. This method is also known as First In First Out (FIFO). It is implemented by Deque, PriorityQueue, ArrayDeque.
import java.util.*;
public class queuefunctions {
public static void main(String[] args) {
Queue<integer myqueue=new LinkedList();
Scanner sc=new Scanner(System.in);
int option;
do{
System.out.println("1. Enter a new integer value to add in the queue");
System.out.println("2. Removing the top element in the queue ");
System.out.println("3. Find the size of the queue");
System.out.println("4. Printing the whole queue");
System.out.println("5. Exit");
System.out.println("Please write an option: ");
option=sc.nextInt();
switch(option) {
case(1):
System.out.println("Please Enter the value to add: ");
int temp=sc.nextInt();
myqueue.add(temp);
break;
case(2):
myqueue.remove();
break;
case(3):
System.out.println("The size of Queue is: "+myqueue.size());
break;
case(4):
System.out.println("The queue is as follows: "+myqueue);
break;
case(5):
break;
}
}while(option!=5);
}
}
3. Set
It is a collection of objects which doesn’t allow the same values in the same set i.e, each value will be different in a set. So whenever we need unique values we use them to set in our programs. It is implemented by TreeSet, LinkedHastSet, and many more. We can create set objects with these classes.
import java.util.*;
public class setfunctions {
public static void main(String[] args) {
Set<integer myset = new HashSet<integer();
Scanner sc=new Scanner(System.in);
int option;
do{
System.out.println("1. Enter a new integer value to add in the set");
System.out.println("2. Enter the index on which the element you want to be removed");
System.out.println("3. Find the size of the set");
System.out.println("4. Printing the whole set");
System.out.println("[...]
8 539
Java Collection Hierarchy
The collection is a framework in java. It contains some of the most used classes which are present in the interfaces. Collection interface mainly has 3 child interfaces and these are as follows.
Image Source
1. List
It contains an order of all the objects. This interface also helps you to have a dynamic size of arrays according to the number of objects present. It is implemented by Vector, Stack, ArrayList, and LinkedList. Therefore we can create a list object with these classes.
import java.util.*;
public class list {
public static void main(String[] args) {
List<integer mylist=new ArrayList();
// Instead of ArrayList we can write LinkedList, Vector or Stack
}
}
ArrayList
Arraylist is a kind of dynamic array that stores values of all data types. It costs constant amortized time to add an element in ArrayList. Let’s look at the code to see different methods in ArrayList.
import java.util.*;
public class arraylistfunctions {
public static void main(String[] args) {
ArrayList<integer arrlist=new ArrayList();
Scanner sc=new Scanner(System.in);
int option;
do{
System.out.println("1. Enter a new integer value to add in the arraylist");
System.out.println("2. Enter the index on which the element you want to be removed");
System.out.println("3. Find the size of the Arraylist");
System.out.println("4. Enter the index of the element you want to be printed");
System.out.println("5. Exit");
System.out.println("Please write an option: ");
option=sc.nextInt();
switch(option) {
case(1):
System.out.println("Please Enter the value to add: ");
int temp=sc.nextInt();
arrlist.add(temp);
break;
case(2):
System.out.println("Please Enter the index of value to remove it");
int ind=sc.nextInt();
arrlist.remove(ind);
break;
case(3):
System.out.println("The size of Arraylist is: "+arrlist.size());
break;
case(4):
System.out.println("Enter the index: ");
int index=sc.nextInt();
System.out.println("The value is: "+ arrlist.get(index));
break;
case(5):
break;
}
}while(option!=5);
}
}
LinkedList
It uses a doubly linked list while storing the values, so getting the first & last value takes constant time. As compared to ArrayList the manipulation is faster because of storing data in the doubly linked list. Its methods are quite similar to the ArrayList.
Vector
Vector also works as a dynamic array. It is advised to use vector in thread-safe implementations otherwise we should use ArrayList in all other cases. Let’s look at the below code to see its functions.
import java.util.*;
public class vectorfunctions {
public static void main(String[] args) {
Vector<integer myvec=new Vector();
Scanner sc=new Scanner(System.in);
int option;
do{
System.out.println("1. Enter a new integer value to add in the Vector");
System.out.println("2. Enter the index on which the element you want to be removed");
System.out.println("3. Find the size of the Vector");
System.out.println("4. Enter the index of the element you want to be printed");
System.out.println("5. Printing the whole vector");
System.out.println("6. Exit");
System.out.println("Please write an option: ");
option=sc.nextInt();
switch(option) {
case(1):
System.out.println("Please Enter the value to add: ");
int temp=sc.nextInt();
myvec.add(temp);
break;
case(2):
System.out.println("Please Enter the index of value to remove it");
int ind=sc.nextInt();
myvec.remove(ind);
break;
case(3):
System.out.println("The size of Vector i[...]
