Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

S Fox

Rancher
+ Follow
since Mar 15, 2016
S likes ...
Eclipse IDE C++ Java
Cows and Likes
Cows
Total received
13
In last 30 days
0
Total given
3
Likes
Total received
32
Received in last 30 days
0
Total given
19
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by S Fox

to shorten up the code these things should just be 1 line.


also, can you explain to me what this line is, do we have pointers in java now?
( i know its probably a lambda of some sort )
4 months ago
i suppose the ttf collection is based on locality? java does have a way to set the localization, i've never done it but i think it has something to do with resource bundles...
maybe if you set up the localization stuff you could get it to work how you want it
5 months ago
lambdas can make your code become either more readable or less readable. it could go either way. the biggest benefit for lambas that i've seen in my code is that it reduces event triggers from a block to a single line of code. i don't know if that improves the performance or not, but my javaFX controller class is far less cluttered that way.

i'm not one who can talk much about streams, but if you're doing multi-threading you'll want to use parallel streams, and you need to be careful about the order of execution. serial streams are leaving performance on the table.
5 months ago
unless i'm misunderstanding whats going on, i think you are comparing the same variable to itself on line13. that's what i was trying to tell you with my last post.
so what i think you need to do is something like this:

add this as line4: minName = input;

and then...

change line13: if(input.compareTo(minName) < 0)


5 months ago
i gave you a cow piet, because i didn't know you can do formatting like this.
i thought you can only do formatting with printf.
5 months ago
6: if(input.equals("")) // if input is an empty string, evaluates true
8: if(input.compareTo(input) < 0) // if empty string compareTo empty string < 0 ... i'm not sure if that evaluates as true or not, probably not
10: minName = empty string // if line8 was true, minName becomes empty string. and if line8 was false minName was already an empty string when it was initialized.

this means you will see minName as an empty string when it's printed on line15.
also you forgot to show in your code here where you declared minName.
5 months ago
i'm not sure if css works for swing, but you can definitely give labels a color in swing so that's why i suggested it. because if you try to do this with just a textarea i don't think you can set colors for individual words. you basically need a seperate object for each bit of text you want to color differently.
5 months ago
i think his confusion is because of this line here:


this command says to make the value of "a" uppercase, and then assign it to "b".
but afterwards when you print the value of "a" it's still in lowercase, even though we said for "a" to be made upper.

and i'm pretty sure the reason for this behavior is because java is pass by value???
so immutability of strings isn't what protects the value of "a" from changing.
5 months ago
it depends on how you are displaying the words in your app, i use javaFX and it has an object called Text. So with that i can parse a string looking for "yes" or "no" and create a seperate Text object, give it a css styled color red or green. since you are probably using swing you could do this using Label objects instead.
5 months ago
if your keys are unique, you could take the k/v pairs into 2 seperate hashmaps, and compare by the K/V entry sets. since none of the data is sorted, this might prove fastest. and if you do want to sort it, just use a treemap.
5 months ago
i can't remember if swing supports a css file, but this is how i am using ttf font with javaFX

in the css file do this:


also make sure your project settings on your ide are using UTF-8, because these settings can interfere with fonts.
5 months ago
some tips:
#1 you define/assign minName on line1, but then you re-assign it on line5 without having ever used it. just assign it on line5 and get rid of line1.
#2 line4 is useless because you are printing this in your while loop on line10, so delete line4.
#3 a break statement is almost never needed, always try to avoid using the break statement. having a break on line16 means the while loop isn't even looping.
#4 don't put too many extra spaces in your code

what you are doing right now is comparing two words when the input is still being generated.
what you could do instead is first just take all the input you get into a list, and then sort the list or return your result after the input is finalized.
either way works.
5 months ago
there's definitely a lot more to learn which might not even be a part of java, but java developers are routinely using. git, maven, spring, javaFX, guava, servlets, kotlin. all kinds of stuff. i think this is what makes it really hard to get into working on existing projects, they use all this extra stuff.
5 months ago
is there any real difference between saving a large amount of table data into xml instead of as strings in a csv file? they're both ascii. would a binary format read/write the data faster?
5 months ago
here's a few hints to help you fix it
#1 define the method (you have done this)
#2 call the method (you haven't done that...)

also keep in mind if you define the double yourValue inside a method (line 10), it will only have scope in there.
that means, you won't be able to see yourValue from main when you try to print it (line 19)
5 months ago