Skip to main content
19 events
when toggle format what by license comment
Apr 13, 2017 at 12:40 history edited CommunityBot
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Dec 18, 2014 at 23:59 history edited Jamal CC BY-SA 3.0
Retained original code (was edited after answers)
Sep 7, 2013 at 9:19 comment added Somjit Nag I feel extremely embarrassed to say that it does. I searched so many times in that class , i only found it now , inside a method called isEmpty(). Kindly accept my apology. Problem solved i guess.
Sep 7, 2013 at 8:47 comment added JohnMark13 You have misunderstood at least some of the question, just because your public API is limited to the main method I do not see a restriction on what you can do beyond that. I do not see a restriction on Java packages either. So now, are you sure StdIn doesn't have a hasNext() method too?
Sep 7, 2013 at 8:36 history edited Somjit Nag CC BY-SA 3.0
added 1428 characters in body
Sep 7, 2013 at 8:11 answer added 200_success timeline score: 1
Sep 7, 2013 at 7:38 history edited Jamal CC BY-SA 3.0
deleted 14 characters in body
Sep 6, 2013 at 20:18 history edited Somjit Nag CC BY-SA 3.0
deleted 200 characters in body
Sep 6, 2013 at 19:54 answer added JohnMark13 timeline score: 2
Sep 6, 2013 at 19:54 comment added Somjit Nag @tintinmj i also mentioned that iv created the stdin class as a stand in for the class provided to us , and to make this an SSCCE. Im editing this back to the actual thing. SSCCE attempt is causing more confusion i suppose.
Sep 6, 2013 at 19:52 comment added JohnMark13 I think that the 'stdin' class is a distraction which is why I suggested it were removed from the example.
Sep 6, 2013 at 19:50 comment added Anirban Nag 'tintinmj' You said I cannot use any other library than java.lang. Then why are you using java.io and java.util?
Sep 6, 2013 at 19:27 comment added Somjit Nag The entire structure is because of the api that i have to maintain. This is an assignment for a princeton MOOC going on at coursera , and the api they gave allows only the main() method. Trust me , It was a pain to mould to the api.
Sep 6, 2013 at 19:22 history edited Jamal
edited tags
Sep 6, 2013 at 19:21 comment added Somjit Nag I'v edited my original post a bit. What i'm trying to do here is implement Reservoir Sampling edit : i know ,those were great solutions , but im stuck with this api. And iv never used exceptions to control flow. So i was asking if that part was ok.. btw, what is RTE ?
Sep 6, 2013 at 19:20 comment added JohnMark13 Just saw your edit. There are some excellent answers on the other thread. Sorry I know nothing about Resevoir Sampling but it seems that you got some great feedback. The use of the RTE is wrong, if you could update the question to make it very clear why you have to use it, and why everything has to be in the main method (as if required a separate function that catches the RTE, logs it (in your case as Unusual termination of stream to System.out I guess) and returns null to terminate your loop in the manner intended.
Sep 6, 2013 at 19:16 comment added JohnMark13 Well possibly the task is bananas. Could you edit the post with what you are trying to achieve and the exact limitations of the question. If stdin is nothing to do with your solution maybe delete it and define the interface you have been given. A few easy things to tidy up though are the naming, there is no limit of characters - i, r, k, s do not convey enough information. Making it clear regarding the unusual reuse of i. Using a while loop in the second instance once we've discovered that i is being weirdly used. Are you just picking a random sample of 3 from stdin?
Sep 6, 2013 at 19:09 history edited Somjit Nag CC BY-SA 3.0
added 206 characters in body
Sep 6, 2013 at 18:38 history asked Somjit Nag CC BY-SA 3.0