Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!

Tess Jacobs

Ranch Hand
+ Follow
since Feb 07, 2012
Cows and Likes
Cows
Total received
3
In last 30 days
0
Total given
0
Likes
Total received
5
Received in last 30 days
0
Total given
25
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tess Jacobs

You can analyse REST security features (in comparison to SOAP).

You can look into the development of RESTful web services in a cloud environment.

Get some ideas by doing a Google search like

"representational state transfer" abstract thesis filetype:pdf
7 years ago
A heavyweight framework (like EJB 2.0 and Struts 1.2) is invasive i.e. it forces developers to write classes that are locked into the framework. This makes your classes difficult to test.

Spring on the other hand is lightweight because it allows minimally invasive development with POJOs. A lightweight framework makes itself as invisible as possible. One of the ways it does this is by encouraging POJO-oriented development. Classes in a Spring-based application often have no indication that they’re being used by Spring because as much as possible, Spring doesn’t force you to implement a Spring API interface or extend a Spring API class. This makes your classes easier to test. It also makes it easy to migrate your classes to another lightweight container.
7 years ago

Paweł Baczyński wrote:It does not compile.


The second example prints hello

Henry Wong wrote:How did one topic of discussion lead to the other topic of discussion?


I misunderstood the comment posted by @Paweł. In the statement String c = g();, I thought he was implying that c is a compile-time constant.
7 years ago

Paweł Baczyński wrote:Method g() returns String "abc" which is in a String pool because it is a compile time constant.


Am I correct in assuming that the String returned by g() is not a compile-time constant because it is not known at compile-time?

In the following code, x is not a compile-time constant and this is the reason for the compiler error.

In the following code, x is a compile-time constant and so there is no compiler error.
7 years ago
Perm gen space (metaspace in Java 8) is used to store Class objects.

According to docs.oracle.com

Instances of the class Class represent classes and interfaces in a running Java application.


7 years ago
In my NetBeans installation, the code I posted earlier is able to pick up an image saved in the \build\classes\images folder.
7 years ago
Put your image in an images folder. Make sure the images folder is in your classpath. You can then access your image as follows:

new ImageIcon(getClass().getResource("/images/Nature.jpeg"));
7 years ago
Welcome to JavaRanch.
7 years ago
Many thanks.
7 years ago
I attempted to modify the FAQ but got this error message:

The changes to this page were rejected because a banned word or phrase was used.

BEFORE MODIFICATION ATTEMPT


AFTER MODIFICATION ATTEMPT


PAGE FORMATTING CODE
The '6' comes from the last index in the String '''ab34ef''' i.e. index 6. This index contains a ''zero-length substring'' which can be accessed as follows

J[
"ab34ef".substring(6);
]

Note that this index does not contain a ''character'' and so

J[
"ab34ef".charAt(6);
]

will throw

J[
java.lang.StringIndexOutOfBoundsException
]

FURTHER PROPOSED CHANGE
Because a match of zero length is possible, the find() method will check the index following the last character of input.

Because a match of zero length is possible, the find() method will find the zero-length substring at index 6.


7 years ago

abalfazl hossein wrote:Now it's clear for me...



From what I understand (thanks to Henry’s explanation), every index in a string contains a zero-length substring and may contain a character.

The string "ab34ef" contains a zero-length substring at index 6 which can be accessed via substring(6), however, it does not contain a character at index 6 and so charAt(6) will throw java.lang.StringIndexOutOfBoundsException

Similarly, the string "" contains a zero-length substring at index 0 which can be accessed via substring(0), however, it does not contain a character at index 0 and so charAt(0) will throw java.lang.StringIndexOutOfBoundsException
7 years ago

Henry Wong wrote:There is no such a thing as a zero-length character.


My mistake

I learnt from this webpage that a zero-length match can occur at several positions in an input string:
  • at the beginning of an input string
  • in between any two characters of an input string
  • after the last character of an input string

  • I thought that these positions were peculiar to regex. It's interesting to learn that java recognizes these positions too.

    And thanks for the cow.
    7 years ago

    Henry Wong wrote:It may be a good idea to read the article again.


    I think the source of confusion and main reason why this question has been asked so many times since 2005 is that in java, nothing exists after the last char in a string (i.e. charAt(6) doesn't exist); however, in regex (which java implements via a standard library), a zero-length character does exist after the last char in a string. Maybe the SCJP FAQ article doesn't make this fact very clear.
    7 years ago
    Thanks.
    7 years ago