Чашечка Java
Відкрити в Telegram
Лучшие материалы по Java на русском и английском Разместить рекламу: @tproger_sales_bot Правила общения: https://tprg.ru/rules Другие каналы: @tproger_channels
Показати більше8 282
Підписники
-124 години
-37 днів
-7130 днів
Архів дописів
8 282
5 Difference between Iterator and ListIterator in Java?
The Iterator is the standard way to traverse a collection in Java. You can use Iterator to traverse a List, Set, Map, Stack, Queue, or any Collection, but you might not know that there is another way to traverse over List in Java? Yes, it's called the ListIterator. There are many differences between Iterator and ListIterator in Java, but the most significant of them is that Iterator only allows you to traverse in one direction,I mean forward, you have just got a next() method to get the next element, there is no previous() method to get the previous element.
Java Interview questions and tutorials
Read: http://www.java67.com/2016/09/5-difference-between-iterator-and-ListIterator-in-java.html
8 282
HelloWorld Program in Java with Example
First of all, welcome to the exciting world of Java programming. If you are ready to write your first Java program i.e. HelloWorld in Java, it means you already crossed major hurdles to start Java programming, in terms of installing JDK and setting PATH for Java. If you haven't done so then you can follow those tutorials to install JDK in Windows 7 and 8 and setting PATH for Java. Before we start writing HelloWorld in Java, few notes about editors. Many Java beginners insist or try to use Eclipse or Netbeans IDE from the very start of the first program, which is not a good idea.
Java Interview questions and tutorials
Read: http://www.java67.com/2013/03/helloworld-in-java-how-to-write-compile-example-tutorial.html
8 282
Difference between GenericServlet vs HttpServlet in Servlet JSP - J2EE question
Difference between GenericServlet and HttpServlet is one of
the classic Servlet
Interview Question, asked on many Servlet
and JSP Interviews on 2 to 4 years experience developers. Since both GenericServlet and HttpServlet form the basis of Servlets its important to know What are they and What is main
difference between them. From common sense and there names, its obvious that
GenericServlet is a generic and protocol-independent implementation of Servlet
interface while HttpServlet implements HTTP protocol specifics. If you are
working in Java web application or J2EE projects, you are most likely to deal
with HttpServlet all time as HTTP is main communication protocol of
web. In this Servlet JSP article we will outline some important difference between HttpServlet and
GenericServletwhich is worth knowing and remembering.
Java Interview questions and tutorials
Read: http://www.java67.com/2012/12/difference-between-genericservlet-vs-httpservlet-jsp.html
8 282
How to iterate over HashSet in Java - loop or traverse Example
Iterating over HashSet in Java
In our last Java collection tutorial, we have seen How to iterate over ArrayList in Java and in this tutorial we will see How to iterate over HashSet in Java. There are two ways to iterate, loop or traverse over HashSet in Java, first using advanced for-each loopadded on Java 5 and second using Iterator which is a more conventional way of iterating over HashSet in Java. Now questions are When should you use for loop and when Iterator is an appropriate option. Well I usually use for loop If I only read from HashSet and doesn't remove any element, while Iterator is preferred approach. You should not remove elements from HashSet while iterating over it in for loop, Use Iterator to do that.
Java Interview questions and tutorials
Read: http://www.java67.com/2012/10/how-to-iterate-over-hashset-in-java.html
8 282
How to Fix java.lang.VerifyError: Expecting a stack map frame at branch target 14 in method at offset JDK 7 [Solved]
Hello guys, today, we'll take a look at the not-so-common error for Java applications. If you have been working in Java for a couple of years then you might have seen this dreaded "java.lang.VerifyError: Expecting a stack map frame at branch target 14 in method at offset JDK 7"error in your application log or in Eclipse, particularly if you are running your Java application in Java 7. The main cause of this error,"java.lang.VerifyError: Expecting a stack map frame at branch target ... in the method ... at offset 0 error comes when you have some library, JAR file which is only compatible with Java 1.6 or below and you are running your program in JDK 1.7.
Java Interview questions and tutorials
Read: http://www.java67.com/2020/04/javalangverifyerror-expecting-stack-map.html
8 282
When to throw and catch Exception in Java? [Best Practice]
Exceptions are one of the confusing and misunderstood topics in Java, but at the same time, too big to ignore. In fact, good knowledge of Errors and Exception handling practices is one criterion, which differentiates a good Java developer from an average one. So what is confusing about Exception in Java? Well, many things like When to throw Exception or When to catch Exception, When to use checked exception or unchecked exception, should we catch errors like java.lang.OutOfMemoryError? Shall I use an error code instead of an Exception and a lot more? Well, I cannot answer all these questions in one post, so I will pick the first one when to catch or throw any Exception in Java.
Java Interview questions and tutorials
Read: http://www.java67.com/2021/06/when-to-throw-and-catch-exception-in.html
8 282
How to Fix java.sql.BatchUpdateException: Error converting data type float to numeric - Java + SQL Server
This error can come if you are inserting or updating a NUMERIC column in the Microsoft SQL Server database from a Java Program using the executeUpdate()method, I mean executing a batch update query. It could also happen if you are calling a stored procedure and passing a float value corresponding to a NUMERIC column, and the value happened to be out-of-range like generating "Arithmetic overflow error converting numeric to data type numeric"on the SQL Server end. For example, if your column is defined as NUMERIC (6,2) the maximum value it can represent is 9999.99, not 999999.99.
Java Interview questions and tutorials
Read: http://www.java67.com/2019/04/javasqlbatchupdateexception-error-converting-data-type-float-to-numeric.html
8 282
How to Fix SQLServerException: The index is out of range? JDBC Example
I was executing a stored procedure against SQL SERVER 2008 database from Java program using CallableStatement, but unfortunately, I was getting the following error "SQLServerException: The index 58 is out of range". Since I am passing a lot of parameters I thought that something is wrong with a number of parameters I was passing to the stored proc. My stored procedure had 58 INPUT parameters, as soon as I removed the 58th INPUT parameter the error goes away, which confirmed my belief that SQL Server supports a maximum of 57 INPUT parameters in stored procedure via JDBC.
Java Interview questions and tutorials
Read: http://www.java67.com/2015/12/sqlserverexception-index-58-is-out-of-range-SQL-SERVER-stored-proc.html
8 282
How to deal with java.lang.NullPointerExceptionin Java? Cause, Solution, and Tips to avoid NPE
Hello Java programmers, if you want to learn what is NullPointerExcpeiton in Java and how to deal with NullPointerException or NPE then you have come to the right place. NullPointerException in Java is an unchecked
Exception defined in java.lang package and comes when a member
of an object either field or method is called on an object which is null. null
is a keyword in Java that means nothing and the calling method on an object whose
value is null will result in NullPointerException. Since the default value of Object
is null, if you call any method or access any field on an Object which is not initialized will throw NullPointerException.
Java Interview questions and tutorials
Read: http://www.java67.com/2021/05/how-to-solve-nullpointerexception-in-java.html
8 282
How to solve java.sql.BatchUpdateException: String or binary data would be truncated in Java JDBC? [Solution]
Recently I was working in a Java application that uses Microsoft SQL Server at its backend. The architecture of the Java application was old i.e. even though there was heavy database communication back and forth there was no ORM used like no Hibernate, JPA, or Apache iBatis. The Java application was using an old DAO design pattern, where the DB related classes which are responsible for loading and storing data from the database was calling the stored procedure to do their job. These stored procedures take data from Java applications and insert it into SQL Server tables.
Java Interview questions and tutorials
Read: http://www.java67.com/2016/10/how-to-solve-javasqlbatchupdateexception-string-or-binary-data-would-be-truncated.html
8 282
How to deal with Unsupported major.minor version 55.0, 57,0, 60.0, 61.0 in Java + Eclipse + Linux [Solution]
The "unsupported major.minor version 55.0"error started to come after Java SE 11 release and the root cause of this error is trying to run a Java application compiled with JDK 11 into a JRE lower than Java SE 11 like JRE 9 or JRE 8. This is very common because a developer has updated their compiler or IDE to Java SE 11 but many times their runtime is not upgraded to Java 11. If you remember, in Java you can run a class file compiled with a lower version say Java 8 to a higher version say JRE 11 because Java is backward compatible but vice-versa is not allowed. I mean, you cannot run a JAR file or class file created by Java 11 version into Java 8 or Java 9 version. Similarly, you cannot run a Java SE 17 compiled class file in Java SE 11 or Java SE 13 runtime environment.
Java Interview questions and tutorials
Read: http://www.java67.com/2016/06/unsupported-majorminor-version-520-in-java-eclipse-linux.html
8 282
How to Fix java.lang.NoClassDefFoundError: org/dom4j/DocumentException [Solution]
Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException comes when your program is using the DOM4j library but necessary JAR is not present. This error can also come when you are indirectly using the DOM4j library like when you use the Apache POI library to read the XLSX file in Java, this library needs dom4j.jar in your classpath. Not just this one but there are several other libraries that use this JAR internally, if you are using any of them but don't have this JAR then your program will compile fine but fail at runtime because JVM will try to load this class but will not be able to find it on the classpath.
Java Interview questions and tutorials
Read: http://www.java67.com/2015/06/org.dom4j.DocumentException-javalangnoclassdeffounderror.html
8 282
[Solved] Exception in thread "main" java.lang.IllegalStateException during Iterator.remove() in Java
Hello guys, if you are wondering how to deal with java.lang.IllegalStateException while trying to remove elements from ArrayList in Java then you have come to the right place. In this article, I am going to share how I solved this problem and how you can do the same. I was writing a sample program to demonstrate how to remove elements from the list while iterating over it by using the Iterator.remove() method. Unfortunately, I was getting the following error, right at the place where I was calling the Iterator.remove() method :
Java Interview questions and tutorials
Read: http://www.java67.com/2016/01/exception-in-thread-main-java.lang.IllegalStateException-Iterator-remove.html
8 282
Хотите создавать высококлассные приложения на Java? Осваивайте Spring
25 апреля в 20:00 приходите на открытый урок «Свойства Spring-приложения».
На встрече разберут, каким образом можно определять настройки приложения на чистом Spring, а также затронут тему конвертации типов.
Спикером выступит преподаватель Александр Оруджев, Senior Software Engineer.
Вебинар состоится в рамках запусках онлайн-курса «Разработчик на Spring Framework» в OTUS. Сейчас курс доступен в рассрочку.
Для участия пройдите вступительный тест: https://otus.pw/o4bh/
Реклама ООО «Отус Онлайн-Образование» LjN8KUsJs
8 282
В какой сказке встречаются Баба Яга и Колобок или сказ о том как мы таск-трекер писали, часть вторая
Всем привет, как и обещали, публикуем продолжение. Первая часть, напомню, здесь (если не читали, то лучше начать с нее, чтобы картина была цельной).
Читать: https://habr.com/ru/companies/rostelecom/articles/721876/?utm_campaign=721876
8 282
Oracle expands availability of Java 8 performance pack
Read: https://www.infoworld.com/article/3694070/oracle-expands-availability-of-java-8-performance-pack.html#tk.rss_java
8 282
What is Synchronized Keyword and Method in Java? Example
synchronized keyword in Java is one of the two important keywords related to concurrent programming in Java, the other being a volatile keyword. the synchronized keyword is used to provide mutual exclusion, thread safety, and synchronization in Java. Unlike Volatile keyword, synchronized keyword is not an application to instance variable and you can only use synchronized keyword either with synchronized method or block. synchronized keyword work with the concept of lock, any thread which holds a lock on which synchronized method or block is locked, can enter otherwise thread will wait till it acquires the lock. In Java programming language every object holds a lock and every class holds a lock, like two String objects s1, s2 holds two different object lock,s and String.class is used to represent class lock.
Java Interview questions and tutorials
Read: http://www.java67.com/2020/04/synchronized-keyword-method-and-block.html
8 282
Создаем eval через байт-код JVM
В интерпретируемых языках программирования (или в языках, которые включают возможность компиляции в runtime) есть возможность вычисления значения выражения, полученного из внешнего источника (например, для построения графика функции, введенной пользователем) с подстановкой актуальных значений переменных. Но JVM изначально ориентирована на компиляцию перед выполнением и механизма, аналогичного eval, в JVM нет (кроме, конечно, возможности использования Nashorn и использования eval в JavaScript-коде). В этой статье мы рассмотрим пример динамической генерации байт-кода из математического выражения.
Читать: https://habr.com/ru/companies/otus/articles/730160/?utm_campaign=730160
