Elya Matsunomi

Ranch Hand
+ Follow
since Jan 23, 2019
Merit badge: grant badges
Cows and Likes
Cows
Total received
2
In last 30 days
0
Total given
0
Likes
Total received
3
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Elya Matsunomi

Any locale specific behavior is defined by the pattern that you provide as well as the subformats used for inserted arguments.



However, If I try this code


The result is
US
$1,234,567.00
UK
£1,234,567.00

As you can see, MessageFormat follows the locale arguments. I only define the "currency" format style in my pattern. However, I didn't specify which country's currency to use in my pattern. I want to know what's the meaning of "locale specific behavior" in this context
1 year ago
According to javadocs:

Note: MessageFormat differs from the other Format classes in that you create a MessageFormat object with one of its constructors (not with a getInstance style factory method). The factory methods aren't necessary because MessageFormat itself doesn't implement locale specific behavior. Any locale specific behavior is defined by the pattern that you provide as well as the subformats used for inserted arguments.



However, MessageFormat has this constructor:

I tried this constructor and it formats a currency based on the locale parameter.
What's the purpose of locale parameter if MessageFormat doesn't implement a locale-specific behavior?
1 year ago
When my cmd is in the root folder where the java package that I created is located, java can compile java files successfully. If I move up one folder from the root, java can't compile the files successfully.

So, let's say I have ClassA.java and ClassB.java and they're located in mypackage package.

ClassB.java


ClassA.java


This is the result when my cmd is in the root folder where the java package that I created. As you can see there's no error.


Now, if try to move up my cmd folder path, this happens


How to compile java files if your cmd folder path is not in the root folder where the java package that I created is located?
1 year ago
I'm a beginner in java networking(and network programming in general) and I'm trying out WebSocket interface in java.net.http package. That said, I'm having a problem making it work. So, I have this code:

Once I run the code, I'm having these errors


I'm using apache web server btw. How do I resolve WebSocketHandshakeException? Can I test WebSocket on a localhost? or do I need to configure my apache web server. As of now, I'm using the default settings of apache web server.
Alright, I'll give a simple example of overloaded method:

1st form:


2nd form:


As you can see, the two methods have the same modifiers, return type, method name. However, their parameters are different. In the 1st form, the given value(the value passed to the method) is a value with a data type of double. In the 2nd form, the given value is a value with a data type of float.
2 years ago
You need to know the basic structure of a method definition in order to answer your question. Basically, method consists of modifiers, return type, method name, parameters and then the method body. here's a pseudo-code to better understand the structure of a method definition:

Now, let's create a java method based on this pseudo-code:


public and static keywords are modifiers.
long is a data type that will be returned after its body is executed.
getMaxMinusCurrent is a method name.
long val is a parameter. it consists of a data type and a parameter name.
{} is a method body. Codes inside of these braces are executed once the method is called(or invoked).
return is a keyword that makes the execution exit the method body. If your method has a return type that is not void, you can add a value after the keyword and that value will be returned to the caller once the execution exits the method via return keyword. The data type of the value should be the same as the return type.

Method overloading, to put it simply, is defining methods that have similar construct.
For example:
int findMax(int[]  n1){/*method-body*/}
int findMax(int n1, int n2){/*method-body*/}
In the example above, findMax has two forms: a method with an array parameter and a method with two int parameters.

If you understand my explanation above then, I think you could answer your own question.

I think this blogspot has an alright explanation regarding java methods: Java Tutorial: Methods
2 years ago
Good lord... I forgot about that. I thought 1 byte = 4 bits. I'm going to take a break for a while. My mind is failing me today.
2 years ago
I'm having a hard time understanding the process of the constructor



I wonder why the result is 2570. This is the description about the constructor in the documentation:

Translates a byte array containing the two's-complement binary representation of a BigInteger into a BigInteger. The input array is assumed to be in big-endian byte-order: the most significant byte is in the zeroth element. The val array is assumed to be unchanged for the duration of the constructor call.


So, these are my attempts to understand what's happening

First off, I tried concatenating the bits in the array. So:
concatenate
10101010 = 170
the result above
101000001010 = 2570
the result and my attempted answer are not equal. Although, both answers are somewhat close.

Next, I tried computing the two's complement of bits in the array. So:
10101010 = 01010101 + 1 = 10101010 = 170

My third attempt was to get the two's complement of each array element before concatenating them though the result was the same as the second attempt.

Anyone knows how this works?
2 years ago
Seems like there's no solid solution to this long path name problem then.  Thanks for the help I really appreciate it.
2 years ago
I also tried to compare the windows explorer and java drag and drop on desktop and java drag and drop still has the problem. When I use windows explorer to drag a file with long path name to desktop, It successfully copied the file to desktop. Java, on the other hand, didn't successfully copy the file.

I also noticed that file path of the file with long file name is somewhat weird when I look at its properties in windows explorer

Portion of the path of file with long path name
D:\LOGICA~1\Uploads\

Portion of the path of file with short path name
D:\Logical(Not Installed) Files\Uploads\

Though, The path of the file with long path name that I'm getting in java is normal.

2 years ago
This code has lots of escape sequence errors. I fixed the errors in firstPage. Just do the same with the other pages

2 years ago
So, this is the file uploader without any items


This is the result if I drag and drop file with long path name using windows explorer

In this attempt. the file is successfully loaded to the file uploader all I need to do is to click the upload button

This is the result If I drag and drop file with long path name using java


The problem only happens in files with long path names. Windows explorer drag and drop and java drag and drop work well with file with short path name. When it comes to long path name, Windows explorer drag and drop still works but java drag and drop doesn't
2 years ago
No, I used notepad++ and it displayed the full path of the file.  The full path is also displayed in the web browser when I do drag and drop to the browser. However, File not found error appeared.
2 years ago
So, I encountered a problem where a file couldn't be copied from one place to another using drag and drop feature of java. I think the problem is the pathname because some files that I dragged got copied well except from files with long path names. The program is being run in Windows 7 and I'm aware of Windows 7 path name limit(which is 255-260 according to the sources that I've read). When I used windows explorer to drag files the file with long path name got copied successfully. My solution here is to inform the user about the long file path name and let them shorten the path name. I just wanna know if there's a solution to bypass that long path name problem like windows explorer does?

This is the length of the file that I was talking about


The program is also being used to drag files from the program to a file hosting website and website gives this error

2 years ago