Чашечка Java – Telegram
Чашечка Java
8.86K subscribers
3.86K photos
12 videos
56 files
6.32K links
Лучшие материалы по Java на русском и английском

Разместить рекламу: @tproger_sales_bot

Правила общения: https://tprg.ru/rules

Другие каналы: @tproger_channels
Download Telegram
How to compare two Arrays in Java to check if they are equal - [String & Integer Array Example]

Hello guys, one of the common Programming, the day-to-date task is to compare two arrays in Java and see if they are equal to each other or not. Of course, you can't compare a String array to an...

Read: http://www.java67.com/2014/05/how-to-compare-two-arrays-in-java-string-int-example.html
Top 6 Free Maven and Jenkins Online Courses for Java Programmers in 2021 [ UPDATED]

Hello Java programmers,  if you want to learn Maven and Jenkins and look for free resources like free online courses, you have come to the right place. Earlier, I have shared the best Maven courses...

Read: http://www.java67.com/2018/02/6-free-maven-and-jenkins-online-courses-for-java-developers.html
Fluent setter. Нарушаем конвенцию

Что будет, если возвращать в setter-методе не void, а this, т.е. использовать прием Fluent Interface?
public class SimplePojo {
private String value;

public String getValue() {
return value;
}

public SimplePojo setValue(String value) {
this.value = value;
return this;
}

// equals, hashCode, toString
}

Теперь перепишем типовой кусок кода и получим такое:
private static AssignmentGroupedActivitiesResource create() {
return new AssignmentGroupedActivitiesResource()
.setGrouping(new UserActivitiesGroupingResource()
.setAlignmentScore(1)
.setFocusScore(0)
.setAdvancedGroups(Arrays.asList(
new ProductivityGroupResource()
.setSectionName("Development")
.setColor("#2196f3")
.setSpentTime(5L),
new ProductivityGroupResource()
.setSectionName("Chat")
.setColor("#E502FA")
.setSpentTime(1L)
))
.setPeriodLong(10L)
.setTotalTrackedTime(7L)
.setIntensityScore(2));
}

Для сравнения – как тот же код выглядит без использования приёма:


Читать: https://habr.com/ru/post/577478/?utm_campaign=577478
Static Class, Static Variable, Keyword, and Static Method Examples in Java - Tutorial

What is static in Java
Static in Java is related to class if a field is static means it belongs to the class, similarly static method belongs to classes and you can access both static method and...

Read: http://www.java67.com/2012/11/10-points-about-static-in-java.html
Advantages and Disadvantages of Encapsulation in Java

The word “Encapsulation” means that closing something like we put the main power of the tablet inside the capsule. It is a mechanism that is done to bind the data and protect it from being used by everyone.

After doing encapsulation, the variables and the data of one class cannot be used in another class and this data can be used by the member functions of the same class. Encapsulation can be achieved by adding the private specifier to the variables.

See the below example of how encapsulation can be done:
public class Encapsulation {

static class Student_Details{

private int roll_no, age ;

private String name ;

public int getroll_no() {

return roll_no ;
}
public int getage() {

return age ;
}

public String getname() {

return name ;
}

public void setroll_no(int student_roll) {

roll_no = student_roll ;
}

public void setage(int student_age) {

age = student_age ;
}

public void setname(String student_name) {

name = student_name ;
}

}
public static void main(String[] args) {

Student_Details myobj = new Student_Details() ;
myobj.setname("Rahul") ;
myobj.setage(18) ;
myobj.setroll_no(34) ;

System.out.println("The name of the student is: "+myobj.getname()) ;

System.out.println("The age of the student is: "+myobj.getage()) ;

System.out.println("The roll no of the student is: "+myobj.getroll_no()) ;

}


Advantages of Encapsulation

* Data Protection: The program runner will not be able to identify or see which methods are present in the code. Therefore he/she doesn’t get any chance to change any specific variable or data and hinder the running of the program.
* Flexibility: The code which is encapsulated looks more cleaner and flexible, and can be changed as per the needs. We can change the code read-only or write-only by getter and setter methods. This also helps in debugging the code if needed.
* Reusability: The methods can be changed and the code is reusable.

Disadvantages of Encapsulation

* Code Size: The length of the code increases drastically in the case of encapsulation as we need to provide all the methods with the specifiers.
* More Instructions: As the size of the code increases, therefore, you need to provide additional instructions for every method.
* Increased code execution: Encapsulation results in an increase in the duration of the program execution. It is because more instructions are added to the code therefore they require more time to execute.

So these were the advantages and disadvantages of encapsulation. Comment down below if you have any queries.

Read: Advantages and Disadvantages of Encapsulation in Java.
Насколько быстрее Java 17?

Решение задачи по составлению расписания турнира с разъездами (TTP) — один из вычислительных тестов в нашем наборе

Позавчера вышла Java 17 с кучей новых функций и усовершенствований. Большинство из них требуют изменения кода. Кроме производительности.Просто заменяете JDK — и получаете бесплатную прибавку производительности. Но насколько большую? Стоит ли она того? Для этого мы провели бенчмарки JDK 17, JDK 16 и JDK 11.

Читать: https://habr.com/ru/post/578300/?utm_campaign=578300
How to create a custom tag in JSP? Steps and Example

You can create a custom tag in JSP either by implementing the SimpleTag interface or extending SimpleTagSupport class. Custom tags are introduced in JSP 2.0 in an effort to minimize Java code from...

Read: http://www.java67.com/2021/09/how-to-create-custom-tag-in-jsp-steps.html
10 Essential JVM Options for Java Applications [ Heap Memory, SSL, to Garbage Collection]

Hello guys, this is a brief guide of appropriate JVM options, which you will often see in production Java systems. As a Java developer, you should know what these JVM options mean, their importance,...

Read: http://www.java67.com/2016/08/10-jvm-options-for-java-production-application.html
Top 5 Free Object-Oriented Programming Courses for Java Programmers in 2021 [UPDATED]

The OOP or Object Oriented Programming paradigm allows you to write a program by modeling real-world things in terms of class and object. It makes representing a real-world thing in the programming...

Read: http://www.java67.com/2018/02/5-free-object-oriented-programming-online-courses.html
AWS Lambda с Java: быстро и недорого

AWS Lambda - популярная платформа для разработки serverless-функций, и как Java-разработчик мне нравится иметь возможность использовать эту платформу. Однако, есть некоторые важные моменты, о которых стоит помнить при работе с ней.


Читать: https://habr.com/ru/post/578518/?utm_campaign=578518
Build Your Software Roadmap with QCon Plus; Kristen O’Leary shares Top Topics

During a recent interview, Kristen O'Leary, senior developer relations engineer at Google and QCon Plus November 2021 Committee Member, shared with us the tracks she is most looking forward to at the event this November 1-12.
By Adelina Turcu

Read: https://www.infoq.com/news/2021/09/qcon-plus-top-topics/
Top 6 Free Courses to Learn Web Development in 2021 - Best of Lot

Hello guys, I have been sharing a lot of free online courses and books on various technology and programming language like Python, Java, C++, JavaScript, PHP,  React, Angular, Spring in this blog for...

Read: http://www.java67.com/2018/03/top-5-free-courses-to-learn-web-development.html
Asserting JDK Flight Recorder Events with JfrUnit

JfrUnit may be used to verify whether or not events occurred that impact the performance of the application such as garbage collection and memory allocation. JfrUnit makes it possible to assert events emitted from the application such as memory allocation, IO, or database queries. Custom events may be created with the JMC agent for libraries that don’t emit events themselves.
By Johan Janssen

Read: https://www.infoq.com/news/2021/09/jfrunit-flight-recorder-events/
3 Ways to convert Date to LocalDate in Java 8 - Example, Tutorial

One of the great features of Java 8 is the new Date and Time API which is intended to fix existing issues related to mutability and thread-safety with existing java.util.Date class. But given...

Read: http://www.java67.com/2019/10/3-ways-to-convert-javautildate-to-LocalDate-java8-example.html
10 ways to Learn New Programming language or Tech skills in 2021?

One of the main challenges of being a programmer or software engineer is constant learning. Yes, that's true. As a programmer or developer, 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
Difference between IN, OUT, and INOUT parameters in JDBC Stored Procedure? Answer

Hello guys, Java Database Connectivity, the JDBC API supports three types of parameters, I mean, IN, OUT, and INOUT. They are used to bind values into SQL statements. An IN parameter is the one...

Read: http://www.java67.com/2021/09/difference-between-in-out-and-inout.html
Точка пересечения двух отрезков

Нахождение точки пересечения двух отрезков


Читать: https://habr.com/ru/post/578746/?utm_campaign=578746
Top Java Blogs Weekly: Best of 39/2021

Best of Top Java Blogs, year 2021, week 39

Read: https://www.topjavablogs.com/news/best-of-39-2021
Top 5 Tableau Desktop Specialist Associate Certification Courses and Practice Tests to Crack Exam in 2021 - Best of Lot

Hello guys, if you are preparing for Tableau Desktop Associate Certification or want to become a Tableau Desktop certified associate and looking for the best online courses to start your preparation,...

Read: http://www.java67.com/2020/07/top-5-courses-to-pass-tableau-desktop-specialist-certification-exam.html
Difference between first level and second level cache in Hibernate

The main difference between the first level and second level cache in Hibernate is that the first level is maintained at the Session level and accessible only to the Session, while the second level...

Read: http://www.java67.com/2017/10/difference-between-first-level-and-second-level-cache-in-Hibernate.html
Top 5 Object Oriented Analysis and Design Interview Questions for Programmers, Software Engineers

Testing the design skill of a candidate is quite common in programming job interviews. Questions like, how do you design a vending machine or a traffic control system are very popular in...

Read: http://www.java67.com/2016/07/top-5-object-oriented-design-interview-questions.html