This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!

salvin francis

+ Follow
since Jan 12, 2009
salvin likes ...
Eclipse IDE Google Web Toolkit Java
Forum Moderator
salvin francis currently moderates these forums:
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by salvin francis

Rahul Pandharkar wrote:Write a Programme to accept a prime number and print it's twin prime number.

If I break up this into simple steps, you need the following:
1. Code that can validate a number (e.g. user enters "Rahul")
2. Code that can verify that a number is a prime or not lets call it 'checkPrimeNumber'
3. Use 2. to first validate if number entered by user is prime or not (e.g. user enters 6)
4. Use 2. to validate if number+2 is a prime number or not (e.g. if user enters 31, then 31+2=33 is not prime)

While I think that other steps are pretty straight forward if you know basic java, Step 2. needs an algorithm, what is your approach to solve the same ?
1 day ago
Hi Rahul,
Welcome to coderanch,
Like any other forum, coderanch has a few rules about asking questions, I suggest that you can read:

HowToAskQuestions <-- it’s a link

1 day ago

salvin francis wrote:

  • You don't need to type "return;" at the end of every method

  • Unless your method returns something.
    4 days ago
    Hi Anton Nyagolov,

    Welcome to Coderanch !! I hope you have an awesome time here.

    First of all, it's great to see someone attempting a chatbot as an exercise in just 2 days of learning Java. That's quite an accomplishment.
    As Henry pointed out, I suggest reading about variable scopes to understand how to access data between objects.

    A few points from my end: 
  • your method names do not follow good java naming conventions, I suggest you look at . It's a bit old, but it still holds true for lot of cases.
  • You don't need to explicitly call System.exit()
  • You don't need to type "return;" at the end of every method

  • 4 days ago
    Honestly, I find this question to be too verbose describing each method names and their modifiers and how to call those methods.
    First of call, I suggest that you QuoteYourSources <-- it’s a link
    This can give us an idea about the context of the question. I feel that a programming exercise should tell you what are the required inputs and outputs for a program instead of how it should be written.
    5 days ago
    Also adding to what Campbell asked,
    "package" should be the first line of your source code. Also, the directory where you create your java source code matters. You cannot define two packages in the same java source.
    1 week ago
    I feel that its better to early exit a method if the parameters are not valid. Validation should be the first part of your method code. Personally, I avoid too much indentations and not having an else statement where the if condition does a return is one of my norms.
    1 week ago
    My opinion about this is slightly different...
    First of all, if the if condition returns, then why do you need to write an else condition ?

    eg...One advantage of this is that your code skips an unwanted indentation. Here's an example from Hashmap.Node class:
    1 week ago
    I agree, they are not always good, hence I mentioned that :

    salvin francis wrote:... But to a different person, they may not mean the same.


    salvin francis wrote:This made me this re-think that my acronyms too might not make sense to someone from a different language background

    1 week ago
    @Campbell, How about using characters instead of Strings ? That would probably boost the program even more. I see that just 3 characters: ' ','#', and '\n' are needed.
    @OP, the only import you need is I am not sure why you are using scanner.skip, maybe you can elaborate more on that ?
    1 week ago
    I think that Naming code entities is actually a matter of taste.

    We are humans after all, each person has a different perspective of looking at the world. Some of us are expressive in typing variables/class/methods/documentation. Some of us type the shortest word possible.
    Many times, I resort to using acronyms such as : no, num, id, empId, etc... Typically, these are local variables and I have no issues reading them as number, employee id, etc.. But to a different person, they may not mean the same. I remember that I had to once modify a code that was written in German. All variables/methods/comments were completely foreign to me. This made me this re-think that my acronyms too might not make sense to someone from a different language background.  While we strive for a good naming convention, expecting everyone to follow the same format is simply not practical.

    With regards to long naming conventions, here's an interesting quote from coding horror: (

    codinghorror wrote:Smurf Naming Convention
    When almost every class has the same prefix. IE, when a user clicks on the button, a SmurfAccountView passes a SmurfAccountDTO to the SmurfAccountController. The SmurfID is used to fetch a SmurfOrderHistory which is passed to the SmurfHistoryMatch before forwarding to either SmurfHistoryReviewView or SmurfHistoryReportingView. If a SmurfErrorEvent occurs it is logged by SmurfErrorLogger to ${app}/smurf/log/smurf/smurflog.log

    1 week ago

    Tim Cooke wrote:Dreams are such mysterious things.

    Dreams are such mysterious, there is a cool concept of "lucid dreaming". It means that the dreamer is aware that he/she is dreaming.

    wikipedia wrote:During lucid dreaming, the dreamer may be able to have some control over the dream characters, narrative, and environment.

    I haven't experienced one, but I would love to.
    3 weeks ago
    I don't know much about the subject at hand. But, I would have to comment that reservations of any kind is a bad idea. It raises questions over equality.
    In my country, there are reservations over a lot of places including government jobs, government schemes and education (yes, that's right, education). They have "quota" for woman, "quota" for people belonging to some caste, etc...

    3 weeks ago
    Is there something specific about lambda expressions that you are looking for ?
    Have you read the tutorials : ?

    I suggest that you also have a look at coderanch guidelines:
    ShowSomeEffort <-- it’s a link
    UseAMeaningfulSubjectLine <-- it’s a link
    4 weeks ago