« first day (1399 days earlier)      last day (3560 days later) » 
00:00 - 14:0014:00 - 22:00

12:00 AM
what's your opinion on using generics on java arrays?
:#
private Bag<Integer>[] list;
list = new Bag<Integer>[v];
 
What? Can you even construct generic arrays with generic bounds?
<T> new T[]; is syntax error, right?
 
yup
but i don't see why
instead i could do
list = (Bag<Integer>[]) new Bag[v];
 
Won't it crash runtime? CastCastException?
 
compile time: generic array creation
 
Is Bag a class?
 
12:03 AM
yup its a data structure i made
 
new Bag[v]; <-- how is that a generic array creation?
You just can't cast Bag[] to Bag<Integer>[].
 
well that line works
thats the thing i don't get
heres more context, its for an adjacency list impl for a Graph data structure
yeah
seems like its bad practice, but it works: stackoverflow.com/questions/529085/…
 
How is that bad practice? We do it all the time. Even in Arrays.copyOf().
 
See: E[] arr = (E[])new Object[INITIAL_ARRAY_LENGTH];
 
That line makes me cry.
Jul 19 at 16:17, by Unihedron
@Deprecated
private static <T>T[] drop(final T[] array, final int index) {
    final int l = array.length - 1;
    if (index == l) return Arrays.copyOf(array, l);
    final T[] copy = (T[]) Array.newInstance(array.getClass().getComponentType(), l);
    if (index == 0) System.arraycopy(array, 1, copy, 0, l);
    else {
        System.arraycopy(array, 0, copy, 0, index);
        System.arraycopy(array, index + 1, copy, index, l - index);
    }
    return copy;
}
 
 
6 hours later…
6:26 AM
good mornin Java
 
@BlackWhite GD Mrng
 
 
2 hours later…
8:38 AM
Hello guys. I have a question ban on my SO account so I am not able to post questions on it. I don't know how to remove it as well. I need a help in the implementation of web services in jsp. I am using eclipse and Axis2 runtime for the web services. I created a dynamic web project and created a Java file with the following content
public class CalculatorService {
public int sum(int x, int y)
{
return (x+y);
}

public int diff(int x, int y)
{
return (x-y);
}

public int mul(int x, int y)
{
return (x*y);
Then I right clicked on the file and chose web services and I created a web service
 
> I have a question ban on my SO account so I am not able to post questions on it. I don't know how to remove it as well.
 
Now how to call the web service from a jsp file is my doubt?
 
Improve your previous questions by editing and fix all the problems. The system hates users who tries to hide bad content by deleting and will ban you for low quality contributions you're trying to hide or not. Answer questions and gain reputation points. Stick around and contribute, by editing, gaining upvotes, etc.
 
Tried a lot but in haste. I need a help urgently
 
Maybe you should hire someone.
But to be honest, I've no experience with JSP pages.
Sorreh.
 
8:41 AM
its ok
:)
 
öçğş
 
'ay
 
Loving Turkish characters
 
9:04 AM
I am gonna crazy because of excel sheet row sorting over Java.
 
Oh?
What's the issue?
 
Apachee POI has not any sorting mechanism
You must doing everything yourself
what a shame
I begin thinking; i can leave sorting process to users....
 
Can you use Collections though?
 
Unihedron i am beginner :))
Ok i can investigate Collections using
 
Ah.
 
9:11 AM
wow is really usefull thing
But i must investigate some examples hmm....
 
Hmm...
 
heya people
 
hiya
 
Mr. Awesome is back !
B-)
 
... Hi Mr. Awesome, I'm tired
 
9:22 AM
@Unihedron haven't slept ?
 
Slept at 6, woke up at 9, still can't sleep
 
Work pressure ?
GF pressure ? :P
 
Nope, just regular insomnia :P
 
ahh, you resemble so much myself, when I was in High School ! :P
Guess all boys are the same (Giggles)
 
xP
It's also very manly for you to giggle, but eh
 
9:29 AM
lolz, I didn't find the exact word. The first thing that struck me was That Word
So, still coding bukkit ?
 
Nope, playing at the Shadow's Den

 Wizards Den

Place for all wizards to share spells, words, and having fun w...
 
9:45 AM
heya @ItachiUchiha
 
Heya @BlackWhite
 
heya @Unihedron :)
 
@BlackWhite hey
 
10:26 AM
can someone provide me good source for understanding polymorphism run time and compile time in java
or can someone give me time to clear me these concepts
 
I will grant you time. (gives you time)
 
@ItachiUchiha
sorry i did not understand
 
... I did not understand you either. What are you looking for?
 
actually i m facing difficulty to understand polymorphism concept
i understand till yet polymorphism is a parent class can hold instance of child class
but kb kis waqt kis class ka method call hoga this is the point i m facing difficulty to understand this
@Unihedron
finally i made login using jsp and servlets
 
Read this and this
 
10:31 AM
no they dnt have polymorphism topic
 
11:21 AM
Maybe i can send this excel datas to jTable and sort them in temporary jTable and send sorted data to new output xls file
What you think for sorting excel rows ?
But i dont know yet is jTable as any sorting mechanism
 
@BlackWhite Why do you need the data to be on jTable to sort them ?
 
@BlackWhite it has (TableRowSorter), but I don't know if using that is a good idea. I know nothing at all about POI, but if it gives table rows as a List, I'd use Collections.sort() with that (and if it does not, I'd look at writing a List interface over the functionality myself)
 
Mates
First; I need read inpurt xls file.
Second: I need sorted as column number 3
Third: When data sorted as column number 3 i need sorted each group of column number 3 as column number 4. because column3 has same data sometimes and must be sorted as column 4 in their group.
Really hard quest i think
@ItachiUchiha because POI has not any sorting mechanism
In MS excel or OpenOffice SS simple sorting mechanism you know. Select first sorting column and second sorting column and tataaaa
 
@BlackWhite are you using collection to populate the POI column ?
 
11:37 AM
@ItachiUchiha I directly read excel file and can retrieve data and send them to another output file no problem
I dont use collection
 
@BlackWhite you still dont me
you need sorted data to write to excel sheet, correct ?
 
I can't sorting my problem is :)
 
dotn ??
 
I create FileInputStream and read data from xls
But i don't know how can i sort these rows
 
If you have data... Sort it?
 
11:40 AM
@BlackWhite are you storing the data in array ?
 
No i dont try
Actually i try sorry
 
Geez @BlackWhite I am not able to understand you !
One option !
Read the data from XLS -> Store it in an array/List
 
Just like one row;
[20-08-2014, 10:00:00, 435345, 34535]
 
Use Collections.sort(your list)
of override the comparator
 
If i store rows with above style, how can i sort them as 3rd column in ArrayList?
 
11:44 AM
You can use a custom comparator: docs.oracle.com/javase/7/docs/api/java/util/…
 
^^^ and then use .sort()
 
    while (sheet.getLastRowNum()>=rowindex){
                     rowList.add(sheet.getRow(rowindex).getCell(0)+
                     ", "+sheet.getRow(rowindex).getCell(1)+
                     ", "+sheet.getRow(rowindex).getCell(2)+
                     ", "+sheet.getRow(rowindex).getCell(3)+
                     ", "+sheet.getRow(rowindex).getCell(4));
                     rowindex++;
}
 
4 mins ago, by ItachiUchiha
of override the comparator
of -> OR
 
I store rows in arraylist just like above. Is it true ?
One output is;
[20-08-2014, 10:00:00, 435345, 34535]
 
Hi all
Heya @Unihedron
 
11:54 AM
Heya @Sabಠ_ಠ
 
woops.
Need some help with an algorithm.
I'm trying to make an RLE compressor
but I can't figure out how
aaaa => 4a
 
@Nordehinu will help you.
... Without the ability to chat, yes.
 
@BlackWhite A List* of rows, the format of the rows themselves does not matter (as long as you can get the cell contents). Comparing two rows is up to the custom Comparator. *(an array would work too, using Arrays.sort(), that's what Collections.sort() uses internally anyway)
 
Problem is i need it to be 2-9 in my limits
so aaaaaaaaaaaa => 9a3a
 
12:01 PM
I presume you have a counter for the chars already. Just stop counting at 9 as if it was the last repeated item
 
I don't
what I did was to grab each line
compress
and append it to a string with a delimiter
then print
but I'm quite stuck
lemme finish typing my code and I;ll show u
 
... Use a loop.
 
I meant the compress part. It must be counting the chars somehow
 
sec lemme try
 
@kiheru @ItachiUchiha thanks for the suggestions. I can investigate them.
 
12:09 PM
@kiheru @unihedron pastebin.com/XxWj7xWJ
What's happening with my thing is if my string has a => 1a
but it shouldn't
 
Change
dest.append(runLength);
to
if (runLength != 1)
  dest.append(runLength);
 
I need a limit for 9 as well
so that aaaaaaaaaaa => 9a2a
 
6 mins ago, by Unihedron
... Use a loop.
 
I have it in my loop
but I'm thinking about removing the for loop and putting a while loop
 
an additional condition in the while loop should do the trick. treat 9th repeated item as the last possible, always
 
12:11 PM
stop at 9>
?
 
while (i + 1 < userInput.length() && userInput.charAt(i) == userInput.charAt(i + 1))
Change that
Honestly, did you write this code yourself?
 
I had 1 question to ask? Is this any way to search minus value (-10.22) in text box using java..
 
while ( /* whats already here */ && runlength < 9)
@Tamizharasi What do you mean?
 
Shall i ask any question intermediately?
 
immediately **
Ask away, don't ask to ask.
 
12:14 PM
not like that.. thanks
 
You're such genius ;-;
Thanks ;-;
I didn't @Uni I got it off stack
 
I can tell.
 
Changed it a bit
I never knew about stringbuffer
 
I think charAt(i + 1) is reliably out of bounds at the end of input
 
@kiheru i + 1 < userInput.length()
 
12:16 PM
ahh, missed that
 
@Tamizharasi What do you need?
 
i dun understand what these do tbh
it just works
 
There's always the kind of "programmers" who builds programs by copy-pasting code. You don't want to be that kind.
 
I don't
I feel ashamed of myself. I was writing python like a ninja and now I look like a failure
 
Fev
helo @Unihedron
 
12:18 PM
Yup. It's a good idea to think through the code example you have there, until you know how it works
 
Hello @Fev, meet my new assistant, @Nordehinu
He will be answering most of these questions for me when he gets enough rep to talk here.
 
Fev
who where is he
 
Fev
hahaah that's you
I'm waiting for easy questions to answer on SO
 
Repfarming?
 
Fev
12:21 PM
what does it mean , ? can't find on Dict.
 
Farming reputation, stack overflow slang for camping something and answering mindless questions that are going to be closed otherwise.
Mostly frowned upon.
 
Fev
oh yes, i'm looking for reputations , Im the only one, a star on SO who has reputation 180
lol
 
Good luck!
 
Won't 2 accounts get you banned @Uni?
 
Fev
probably
 
12:23 PM
in Tavern on the Meta on Meta Stack Exchange Chat, 1 hour ago, by Unihedron
Wait, it's not illegal to have alt accounts as long as you're not cheating with it, right? (or so I thought...)
 
Fev
they detect IP
 
6
Q: Using multiple accounts (ethically)

Phil Lello Possible Duplicate: I am a sockpuppet, may I exist if I have a real purpose? I'm considering setting up a second account for ethical uses. Specifically, as I'm here under my real name (used for my normal activities), I'll be at a bit of a disadvantage when it comes to discussing thing...

@Fev Are you assuming?
 
sockpuppet xD
 
Fev
12:26 PM
They detect our IP ??? right?
 
Go read some meta posts.
Hi @Excite
 
Fev
@Unihedron , Oh i get it , I mean Nordehinu is you right ?
 
... Backwards.
 
Fev
@Unihedron , what is the difference between ^[0-9]+$ and ^[0-9]*$ , i'm learning a regex now :D
 
+ is "one to any [greedy]", * is "zero to many [greedy]".
So "" (empty) matches only the second regex, but anything that matches the first will also match the second.
 
12:33 PM
How do I add values to an array ?
 
Fev
ok thank bro..
 
String[] myArray = null;
 
One does not simply
Add values to an array
 
Hmm
I'm trying a for loop
 
@Nord might know, but he still can't speak yet.
 
12:34 PM
But I can't use a for loop I need a while loop
myArray[] = myString;
 
Why do you need a while loop on the first place?
 
Because the text can be of different sizes
Basically I'm doing line by line
 
Arrays have constant size, so you can only assign values to their elements, not add any new ones. In most situations, where you want to use dynamic sizes, use ArrayList instead. OTOH if you know, the size in advance, arrays can be used
 
As long as I have a line I'll compress it and put it in an array
then output the array
Aha
 
arraytype[] arrayname = new arraytype[10]; // arbitrary decl line
 
12:43 PM
I tried arraylist
it strips out the 3 from 3a for example
so if I have
3a
my output is just [a]
:S
 
arraytype[] newarr = Arrays.copyOf(arrayname, arrayname.length + 1);
newarr[arrayname.length + 1] = newelementtoinsert;
arrayname = newarr;
 
I don't get it lol
I can skip the use of array if I find a way to not print the \n in the last line
				text = text + "\n" + RLE.compress(SENTINEL);
 
Read it out loud...
Don't concatenate arrays in a loop. A cute bunny dies. Use StringBuilder.
brb
 
ok
i can't get it
-_-
 
12:58 PM
@Sabಠ_ಠ what is it that you dont get >
 
text = text + "\n" + RLE.compress(SENTINEL);
My output has this trailing new line at the end
So I wanted to use an array, put each RLE.compress(SENTINEL) in the array
and then loop through the array and print
 
...... There's no output until you print to System.out.
 
Ofc there is syso(text) at the end
.
 
instead of doing string concatenation in a loop with '+', use StringBuilder.append() instead. And only after you're done with all appends, you can get the constructed string with .toString() (iirc compress does that, so you can look there for an example)
 
@Sabಠ_ಠ How is that possible ?
 
1:01 PM
^^^ I +50 what he said.
 
My text is basically like this:
3a4d3s\n4f\n
 
what is the output for RLE.compress ?
 
flip
okay nvm about the code
RLE.compress grabs a string and compresses it
e,g aaaaaaaaa => 9a
 
and does it insert the \n as well ?
 
nop
 
1:03 PM
what's the purpose of the while(true) loop? it's executed exactly once due to the unconditional break
 
then where does this come from ?
4 mins ago, by Sab ಠ_ಠ
My output has this trailing new line at the end
 
or does it? return compressedText.toString();
 
!dlroW ,olleH
 
Oh my goodness Hi @Nordehinu I heard you're a Java Ninja
 
Kidding.
 
1:05 PM
@Kiheru ya i removed it
 
Are you trying to remove the new line characters?
 
I'm just trying to make it not print the last \n
 
@Sabಠ_ಠ text = text.substring(0, text.length-1)
:P :P
 
:S
:D
I see
 
text = text.trim();
 
1:07 PM
Or, simply not append a newline unless there's more lines to add
 
@Nordehinu It removes whitespaces
 
I love these hacks <3
 
Though in algorithm, you should just avoid adding that newline anyway.
 
@kiheru it's important to have new lines
 
@kiheru +1
 
1:07 PM
@ItachiUchiha Your method would work, if you do an additional check to make sure the character at the end is a new line.
 
Why?
Aha
 
@Sabಠ_ಠ The most optimal way to do it, will be to check if there are no new lines to add and not add the \n
 
If you want, use regex... text = text.replaceFirst("\R$", "")
 
aha
 
1:08 PM
2 mins ago, by ItachiUchiha
@Sabಠ_ಠ text = text.substring(0, text.length-1)
 
@Sabಠ_ಠ I did not mean removing all new lines; just only adding them if, and only if there's more input
 
I need to sit down and learn java from the beginning I guess
It's going too fast and I'm burning out
 
@ItachiUchiha Do conditional check to assert the last character is a newline first.
if (text.charAt(text.length()) == '\n')
    text = text.substring(0, text.length()-1)
 
removing too, would be more efficient using the StringBuffer
 
Agree.
Too bad they never merged StringBuffer API to StringBuilder!
 
1:11 PM
Welcome @PauloDiogo!
 
meant StringBuilder really :-/ I never use Buffer (Does it actually have any valid use cases? Modifying it in indeterminate order from multiple threads is an obscure situation at least)
 
@kiheru You can use StringBuffer to perform immediate regex replacement. If you use StringBuilder you have to re-assign after every replacement operation.
 
@kiheru Buffer is thread-safe !
its slower, but takes care of multi-threading !
 
@Nordehinu ok, that could be even a valid purpose. I didn't know it
 
@kiheru While both are mutable StrongReference objects to CharSequences, only StringBuffer supports live regex replacement like I've mentioned above. There's also a few rarely used features that comes with StringBuffer over StringBuilder, but most programmers uses StringBuilder - if they're multithreading, they'll have to take good care of the stack anyway.
As such, StringBuffer might actually be rarely used, since it's synchronized and the thread-safety is not always needed.
 
1:20 PM
@ItachiUchiha yeah, it's thread safe but the thread safety it has matters only in such obscure cases that I have never seen one. It's better to handle the synchronization where it matters, rather than at where StringBuffer does it (everywhere, but still fails to guarantee consistent results in many situations).
 
That is correct, as it's synchronized, but not atomic.
Atomic objects are the real hacky magic.
 
1:32 PM
@kiheru Though I accept the cases are very slim to use them, but I just told you the reason they were created ;)
 
Actually, StringBuffer was in the JDK before StringBuilder, I believe.
 
StringBuffer is the older of the two, from the time everything was made thread safe without thinking if the thread safety makes any sense for the object
 
@kiheru true
Consider HashMap and HashTable
Vector and List
 
Yep, those are other good examples of the same
 
I like the append() in StringBuilder, but alas string doesn't have it !
Note : I know String is IMMUTABLE :P
but still I like append() ;)
 
1:39 PM
... "Uni".concat("hedron").equalsIgnoreCase("uniHedron") -> yes
 
@Nordehinu must be some other method then :P
 
+ works very similarly anyway
 
@kiheru yeah, but new objects are created
brb
 
Is there a function to chech if a number is in a string?
Let's say I got a String which is 3 only
I wanna check if its a digit
 
new objects are created with concat too :-D kinda unavoidable with immutable strings
 
1:43 PM
@Sabಠ_ಠ Two ways:
 
String a = "3";
If(a.isDigit()){}
but alas isDigit doesn't exist
 
try {
  Integer.parseInt(str);
  return true;
} catch(NumberFormatException ex) {
  return false;
}
Or
 
can anybody give me a way to remove my question ban
 
return str.matches("-?\\d+");
 
-4
Q: the select query is not executing

subham soniI have written a code for login authentication using select query in asp.net C# in Visual studio 2012. The partial code is String conn = "Data Source=Srinidhi-PC\\sqlexpress;Initial Catalog=model;Integrated Security=True"; SqlConnection con = new SqlConnection(conn); con.Open(); Stri...

 
1:45 PM
Ooohh
 
How can I improve this
question
 
You got trolled badly :(
-4 is always troll :(
 
I asked only three questions
 
@Sabಠ_ಠ there's no String.isDigit(), but there is a Character.isDigit(). That may be useful if you are writing a decompression method since your integers are always 1 long.
 
all the three were downvoted badly
I need to ask a question on jsp
anybody can help?
 
1:49 PM
Yep
 
@subhamsoni Take a tour. Asking questions are hard. Ask them good. Get the best answers. Then the people who answer will upvote your question in return.
 
That's brilliant found it on Google just now lol
THanks :D
 
I'm not sure if you've attempted improving that question. Correct the grammar, look up the internet, post research effort and attempts. Carry a minimal understanding of your code. And reduce noises like ......... and help pls.
 
@Unihedron Now what should I do????
 
Improve it.
 
1:51 PM
done
After improving will the edited question
come up
in the list of new questions
 
Or go answer questions. Answer them good, and get upvotes in return. The system just hates it when users delete bad content to hide them.
Yes, it will be bumped, not like you have any way around that.
 
The system just hates it when users delete bad content to hide them - How is that ? o_O
 
Deleting negative score content increases your chances of getting a ban.
 
Ahh stuck again !
 
Go read up on Meta Stack Overflow.
 
1:53 PM
In my compression
 
@Unihedron Can you throw me a link ?
 
I'm trying to check if it's only 1 digit, if yes then concatenate 1 to it
eg
aaaaa8bbb
5a183b
 
@ItachiUchiha I'm not sure where the relevant post might be, you'd have better chances searching.
 
@Unihedron hmm !
@Sabಠ_ಠ @Unihedron might help as this can be easily done with regex
 
I'm trying to not do it with regex I'm new :S
bascially what does this line do? userInput.charAt(i)
 
1:59 PM
@Sabಠ_ಠ Read it out loud...
 
it's checking if its 1 character
?
 
00:00 - 14:0014:00 - 22:00

« first day (1399 days earlier)      last day (3560 days later) »