verruckt24 438 Posting Shark

@s.o.s & @Ezzaral : Yes completely understand that returning the array index is a very good option in the case where you are writing a library which would be used by thousands, probably even more, and where each usage could have a different reason from the other one. This also sounds to be a good option while developing methods, that are going to be used by your programs, as there's no harm in it.
But my point here is, when the user knows that he is not building an API - he did not suggest that - and the method is going to be used in his program itself, where the purpose of the searching the number too is known beforehand, the option of returning the boolean would not be a bad one.

verruckt24 438 Posting Shark

Thanks man it really helped! Maybe you could train me a little bit, by giving me tasks:D...I would really like that..

I am not understanding this approach of almost begging for help. You have only been asking for training/help/guidance in all of your posts. If you want to train yourself, you would be the best person ever to start giving yourself ideas since you are the one who knows best what you have been studying in the past, whats your grasping speed is like etc etc., You have been given enough pointers on where to start by many here - including myself - but you don't seem to be taking anything from that. You have been asking for help from your first post till the last one and nothing seems to have changed, not even the tone.

if for you motivation equals a paycheck, I would recommend you to go into a different direction.

PS : I agree with Stultuske entirely, even I mentioned this before to you but he does it more concisely.

verruckt24 438 Posting Shark

@s.o.s & @Ezzaral : The question uppermost in my mind here is that what makes the OP not use a boolean return type here which just specifies whether the number queried exists in the array or not. Certainly he has the number, so he doesn't need the method to return it and also what good the index number can be if he already has what is in the array at that position.

I am assuming here he doesn't intend to do some calculations that would require the index number. And if he does intend to I think he should post the method code the next time.

verruckt24 438 Posting Shark

Because you ask for a fancy way, I give it to you. So suppose you want to allow multiple answers without much work you can do this :

Scanner input = new Scanner();
String response = "";
System.out.println("Do you want to continue ?" Yes/Y/No/N);
response = input.nextLine();
do{
// Whatever you want to do
}while(response.toLowerCase().indexOf("y") != -1)

Now your program won't stop for any answer like Yes, yes, Y, y, Yeah, Yep, Why not, and also for ones you say yse,sey,eys,esy (mispellings) - Howzzat ?

Okay that was certainly a funny way of implementing it, only becuase you asked for, but on a more serious note, you should put the conditions, for which you want to allow the user to move ahead, in an OR clause, such as this :

while(response.equalsIgnoreCase("Y") || response.equalsIgnoreCase("Yes"))

You would ask here - what about the mispelled responses ? - Well in that case tell the user about the valid inputs. Ask him once more what he intends to do, may be he will not do the mistake again. The point here is to make sure that the user knows what he is doing.
To prove this point let's take the above example. Say that you have prompted the user with "Do you want to continue ?" in the above case and are waiting for his response. The user types, say, "Not yet" which certainly means he is not ready for giving you an input at this very moment, but the …

Antenka commented: Wow! Impressive speech :P +2
verruckt24 438 Posting Shark

This is because your system is not able to locate java.
Here you have two options :
1. Open a command prompt window. Then write set path=%JAVA_HOME% where JAVA_HOME should be your path to the bin directory in your java installation. So, say for example you have Java installed in your C:\Softwares\Java directoryyou should put the path as set path="c:\Softwares\Java\bin" 2. The option above has to be done for every new shell. Instead of that you can do with a permanent option which is by adding the same java installation path to your PATH Environment Variable.

verruckt24 438 Posting Shark

http://www.javapuzzlers.com/

When you see puzzles that are far more complex than the one you seem to be in really helps you understand how trivial yours is. ;) Masijade has done enough from his side to solve yours. :D

verruckt24 438 Posting Shark

I was just giving an example man. I know . The thing is I want to practice on complicated problems so I can learn new things, and I want to be motivated. Because if I sit here and think, hmmm let's implement Gray Code...I don't feel like doing it. I want to practice on something that the IT jobs are interested in, not on didactic problems, if you know what I mean....

The concepts that I mentioned in the posts are generic enough for any or every program to need them. Most IT organisations would be interested in knowing how much of the language fundamentals you know, domain knowledge is what every organisation has to provide to their new employees. No practicing is going to go waste. The more you practice the more closely are you going to get yourself acquainted with the language and the more comfortable you would be handling questions when you go for an interview. Once you know you have a stronghold over the basic things you can leap towards doing more serious work such as organisational projects.
And if you don't feel motivated enough to do practice programs, I suggest you look for a new domain, cuase if you are going to become a pro programmer that's what what you are going to do pretty much through out your life.

verruckt24 438 Posting Shark

You can find Java EE and Servlet tutorials on the Sun site. For the web mechanism, I do not know what you mean by that term, but if you are meaning the way Servlet's & JSP work, you can find it in the tutorials itself. If not google it and find.

verruckt24 438 Posting Shark

@tavy88 :
You say you have to start practicing java. On the other hand you say "it would be good if someone pays you for that". Tell us why would anybody want to pay someone for giving him/her practice. Also projects that someone might pay you for, would be complex enough to implement, they would need to be stable, robust, efficient at what they do, how do you think a beginner is going to achieve that ?

EDIT : Also, is the joy of learning something new and constantly trying to better yourself at that not motivation enough, to keep you going ?

verruckt24 438 Posting Shark

Assuming you know the index of the element to be converted do:

int anInt = Integer.parseInt(vector.get(index));
verruckt24 438 Posting Shark

You say you have read a lot of theory, why then don't you consider practicing what you learnt in theory. Say for example try the Abstract Classes, Interfaces, Classes, Inner Classes, Exceptions, Threading etc in examples that you might have read in theory. This way you would also be asserting the knowledge gained from theory.

verruckt24 438 Posting Shark

I thought about doing -1 but that could be 1 of the numbers.

Yes that could certainly happen, one of the underlying assumptions there is that the array doesn't contain negative numbers. For the solution, why don't you consider returning a boolean type then ? That would suffice I guess. A true value represents the number existing in the array, a false otherwise.

verruckt24 438 Posting Shark

There's one more thing, that you have been forgetting and which I too skipped in my first post. Should you not reset the index too to zero so that the entire array is scanned once again. What say ?

verruckt24 438 Posting Shark

i think you must try this
method for find max and the same method for min
private int findMax(int a, int b, int c)
{int max=math.max(Math.max(a,b),c)
return max;
}

Have you even taken care to understand what his problem domain specifies ? He clearly mentions that there can be more than 2 nos so it means there can be more than 3 nos too. How does your program work when there are more than 3 numbers ? Will you be able to explain that ? This approach has already been suggested and somebody has already mentioned that this hardcoded approach won't work.
While suggesting solutions remember to read the problem domain correctly, understand it and also don't forget to read the solutions offered by others.

verruckt24 438 Posting Shark

Yes, I agree with stultuske's method of keeping the return type as int and returning -1 where the number isn't found. Besides being simple, this method is a good practice. Using null might cause the caller method to throw a Null Pointer Exception if the exceptional condition is not handled.

verruckt24 438 Posting Shark

take a look at the found1 variable, at first it is false, then when you enter a number that can be located in the array it becomes true

found1 = true;

but then you do not set it to false again before checking for the second number. Then your while loop checks if found1 is false, sicne it is true !found1 returns false and the control would never enter the loop again.

This is what the first impression I get from your program where you might be going wrong, if thats isn't it, let me know.

verruckt24 438 Posting Shark

declare highestVariable and set it to 0
declare lowestVariable and set it to something really high

@BestJewSinceJC : This is not a good idea. Say for example in the first case all the nnumbers in the array are negative. what then ? Your approach would certainly yield the wrong answer. Also in the second case, would you be able to define a really high value ? Also what if all the numbers are greater than that ?

@OP : For this one should set the min and max to the very first numbers from the array and then compare with all the other numbers, modifying the min wherever a lower number is found and modifying the max wherever a greater number is found. In the end min and max have the answers to your question.

PS : I am surprised this thread should be lasting more than 4-5 posts. I think we all have given the OP sufficient material for thought (not to mention masijade gave him the entire solution) and further posts should be submitted after the OP provides proof of effort from his side.

verruckt24 438 Posting Shark

How would i make it in a loop?

@masijade : He he, I knew that would be his next question.

@aodpreacher : Well if you feel your question has been answered, you can mark this thread solved and give masijade his deserved and me (somehwhat) undeserved credit ;)

verruckt24 438 Posting Shark

I just started programming in Java and i dont think i would know how to program a method to make it detect the min/max in an array. is there any method to just use the Math.min/Math.max for trying to see which one is the largest/smallest from the users input?

Yes you may new to java, but are you new to numbers and Math too ?
I am not against using Math.min/max but that's a lame excuse. Can you not compare two given numbers for equality/greater than/lesser than condition are you new to that too ?

verruckt24 438 Posting Shark

You can write a method of your own that, say for example when passed an array of numbers returns the max and the same for min.

verruckt24 438 Posting Shark

Turkmenistan, isn't it ?

This is an easy one :
appa wen euigan

verruckt24 438 Posting Shark

We understood your problem you con visit our site that is helpful for you

Adventure travel is one of the fastest growing travel sectors. Our industry is undergoing a significant evolution to meet the increasing demands of clients and distributors of our products.

for read more Click Here [SNIPPED]

You have confirmed my belief that people go to any lengths to advertise their product, sometimes without even seeing that the help seeker was asking for help more than two years ago. He must have found whatever he had asked for by now, your blind advertising didn't win you any customer here and I hope it never will.

verruckt24 438 Posting Shark

We are not the inventors of the reach algorithm why ask us ? And even if someone gives an answer why belive him when you yourself can check it out for yourself. Ask google I think he might be able to give you a better answer or atleast point to one. What say ?

verruckt24 438 Posting Shark

@praveenhai : Atleast care to take a look at the forum rules for providing homework. How ever on earth can someone ask for a complete project. Do you think we have products ready to sell ? And if yes why should we offer our hardwork for free ?
Commenting about the project work you are asking for, think about it this way if this work has been mandated upon you as a minor/side subject then you shouldn't worry about it much, put together something using the scarce knowledge you have been given, since this is a minor subject, and submit that, it won't bother you much anyways. But, and here's the fact, I think this is your major and you have no clue going about it. In that case don't you feel that asking for readymade stuff like this is only going to further your ignorance of the subject. Try acccumulating the knowledge required for that and try and put up a better show than this, however it would be, good or bad, you would have the satisfaction of doing it on your own rather than having a pat on your back when you don't deserve it, don't you feel the same ?

verruckt24 438 Posting Shark

British Indian Ocean Territory. Is that a country but ? Also u've got the spelling wrong for it ; there should be three Rs in the terrirtory spelling.

Guess this, ibsare oetngmrnoe

verruckt24 438 Posting Shark

Great but aren't you supposed to continue the game by asking the next question.

verruckt24 438 Posting Shark

Actually the decision whether to throw an exception should be made wisely. The reason the throw and throws concepts exists is that that when a programmer feels incapable of handling an exception himself then he can delegate the condition to the next higher level in hope that the caller of the method can handle it himself.
Whether throwing or taking care of the exception, the developer has to catch the exception first.

verruckt24 438 Posting Shark

Have a go at this, YIRVO SOCAT

verruckt24 438 Posting Shark

thats SENEGAL...

verruckt24 438 Posting Shark

@masijade :
When I said an error during compilation I meant that the program may not be compiling correctly and hence he won't see the expected output (the exe file) this certainly isn't an error in the process. Here the process (tcc) would just provide an output underlying the lines and the errors that have occurred within the c program so I said for this you need to get an output stream for the process

verruckt24 438 Posting Shark

Yes but what if the .exe cannot be created for some reason say some compiler error or such, and on that you need to throw something back on the standard output stream for it to be caught by your stream.

verruckt24 438 Posting Shark

There is also a forum for JSP here. We would have liked you searching a bit and getting to know the place before posting directly. Moreover it's much more beneficial for you if you put this question there as you would get help faster.

verruckt24 438 Posting Shark

@stultuske :
No actually he wants to return the nth short word, where short word is a word with less than or equal to three characters. I too got confused with it, but when I saw the code posted by him I got the logic he was trying to explain.

verruckt24 438 Posting Shark

Yes but what output are you expecting from giving the file to turbo C ?
Also try some very simple command such as the one shown - ping. If you still do not get the output, post the entire code you've written, we would like to see that then.

verruckt24 438 Posting Shark
if(words.length <=3)

This is wrong here, the length attribute would give you the length og the array, so for example if you have 5 words in the array, words.length will give you 5. Whereas you have to calculate the lenght of each word in the array.
Here's how you can go about it :
1. Write a for loop that traverses the array till the end of it.
2. for every word within the array check it's lenght in characters by using the length method of the String class, since every element in the array is a String, you can do this with

if (words[i].length()>3){
    wordCnt++;
    if(wordCnt==n){
        shortWord=words[i];
        break;//increment the counter towards n, check it after incrementing, if it is equal to 'n', this is the word you need. Else continue.
    }
}

3. This way you would either reach to the nth short word or the end of teh array, in the former case break from the loop with the nth short word assigned to shortWord in the latter case return a blank/empty string.

verruckt24 438 Posting Shark

You certainly have an extremely fast information network ;)

verruckt24 438 Posting Shark

Well if the stack trace doesn't show anything, then you certainly don't have an error. Maybe the process ran to completion with success. Get an outputstream for the process and check it's output.

verruckt24 438 Posting Shark

The same page where you got this code explains the questions you are asking:

1. If you want to start a process with the default working and without modification of the environment use this :

Process p = new ProcessBuilder("myCommand", "myArg").start();

where,
myCommand = the command that starts the process you want to.
myArg = the arguments that the process thus started might require.
So for example if you want start a ping command you do something like this :

Process p = new ProcessBuilder("ping", "192.168.0.1").start();

2. If you want to start a process where you want to modify the working directory and/or the environment you do this:

ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
 Map<String, String> env = pb.environment();
 env.put("VAR1", "myValue");
 env.remove("OTHERVAR");
 env.put("VAR2", env.get("VAR1") + "suffix");
 pb.directory("myDir");
 Process p = pb.start();

Again here the myArg1 and myArg2 are the arguments that you want to pass to the command.

So taking into consideration what you are doing, try doing this :

ProcessBuilder pb = new ProcessBuilder("tcc", "test.c");

If this does not work, let us know the exact error with the stack trace.

verruckt24 438 Posting Shark

What kind of errors are you looking for ? The spelling mistake you feel the IDE user has made could be variable declaration. Also since a user is free to name his variable anything, until he obeys the language rules for it, you cannot even compare English spellings. What most IDEs offer is highlighting keywords, code completion etc. For this you would have to incorporate the entire library in your IDE for that langauge and offer a quick suitable solution. I am certain this should have some way of doing it in an optimized fashion, but don't know how, you'll need to google for it. For keywords you'll have to have an entire list of all the langauge keywords that you wish to support and on every keypress look for a matching keyword. To choose the list of keywords to check, you'll either have to depend on the filename extension the user selects or some way in which the user explicitly tells you what langauge he is using the IDE for.

verruckt24 438 Posting Shark

@stephen84s :
If you really have some life's frustation that need venting then what the hell are your office team members for. Pour it over to them ;)

verruckt24 438 Posting Shark

The problems would have been a lot less if you agreed at the very first that some of your posts niot in this thread but in the other thread weren't helping the OP. It's your outright denial of the fact that I did not like myself, I am not speaking for others here, they may have their own reasons for their behaviour. It seems that you have taken it too personally. FYI I wouyld like to tell you that there are tens of users that introduce themselves to this forum everyday, it's not that we have something against them, we can't since we all too were new comers someday, but we feel it our moral duty towards this forum that the OP is made aware of the incorrect advice. I did the same and also suggested you where you were going wrong. Also while making you realize of your mistake I certainly did not use any harsh tone or words. You did not accept it, I gave you enough proof of the fact, but there was no acceptance of the fact from yourside and that's what I guess did not went down well with anybody. If you are able to realize and accept your mistakes in life and make an effort towards not repeating them you are a winner in life. It's upto you now.

verruckt24 438 Posting Shark

Where exactly are you getting the problem and what is it. Also mention in a little detail what you want to achieve.

verruckt24 438 Posting Shark

That depends on your SMS Gateway which is also, in messaging terminology, called SMSC or Short Message Service Centre. If your provider uses the HTTP Protocol to have sms sent over to them then you would need to use HTTP POST/GET method. On the other hand if your provider uses the SMPP (Short Message Peer to Peer) Protocol you would have to use the same to connect to them. Then you would become an ESME (Extended Short Messaging Entity) which can be termed as a client and the SMSC acts as the server.
In this case your communication would be through the SMPP Protocol PDUs. You can find out more about the SMPP Protocol on the net. To do this you would require a Java SMPP API using which you can communicate with the SMPP Server. One of the popular Java SMPP Libraries is here. Download it, it comes with the Java Docs. Reading SMPP Protocol Specification would also prove to be helpful.

verruckt24 438 Posting Shark

@~s.o.s~ :
I am afraid sos, but I do have a different opinion here, to prove my stance being correct here let me site you an example of another thread here. If you go through this thread - I think you have already gone through - you would come across my second post to him where I explain to him in the same tone that you ask us to in your above post, that copy-pasting top links without going through much of the OP's actual problem could be misguiding (I use the same word too). But with further reading you would have noticed that he disregards the advice altogether and tries to cover up his act saying that he had gone through the OP's post "carefully" and the examples given by him do really help the OP. Going through the examples yourself and understading the OP's actual problem do you think they were even remotely related ?
I don't think so. This is what was pointed out by me on which stephen84s supported me. The point I want to make here is, I tried telling him the polite way on avoiding the kind of behaviour he showed here. I also adviced him what he should do if he is really short on time, but he was too busy feeling pride in the so called help offered by him. It is the outright denying of wrong behaviour even after doing it and having been told politely about …

verruckt24 438 Posting Shark

The examples you have sited certainly DO NOT catch the cases shimbardy talks about, thats for anybody to tell. Go have a closer look again if you find this surprising rather than covering up your act.

EDIT :

import java.util.*;

/** DateDiff -- compute the difference between two dates.
 */
public class DateDiff {
   public static void main(String[] av) {
      /** The date at the end of the last century */
      Date d1 = new GregorianCalendar(2000,11,31,23,59).getTime();

      /** Today's date */
      Date today = new Date();

      // Get msec from each, and subtract.
      long diff = today.getTime() - d1.getTime();

      System.out.println("The 21st century (up to " + today +
         ") is " + (diff / (1000*60*60*24)) + " days old.");
   }
}

This is the code from one of the site examples you mention, do you think this solves the OP's problem. C'mon now I guess you know what you are saying.

verruckt24 438 Posting Shark

@eng.hosam84 :
I suggest you read the problem domain as specified by the OP, cause I am sure you haven't done that. The reason I say this is because, the first two of the four so called helpful links you have mentioned are completely irrelevant to the OP's question. They are comapring datetime difference whereas the OP is asking for the time difference in the format she has mentioned above. I have gone through both of the links and they do nothing to help the OP's cause.
The third and fourth links mentioned by you come from a site that is not recommended for tutorials, examples etc, since it has been observed that some of their tutorials have been preaching wrong stuff. Still I fail to understand how this site keeps on topping google search results. Now this makes me think that to answer this question you have just entered the search string "time difference" or "date difference" in google and pasted here some of the top results without even taking care to understand the "difference" between the OP's question and your so called answer. Avoid doing this. If you feel that the answer could be found just by googling a few topics advice it to the OP rather than just blindly pasting the top links. Let her search for it, that'll help her too. But if you are short on time and don't want to read and understand the OP's entire problem domain, I suggest you ignore …

verruckt24 438 Posting Shark

You need to split the input in two parts - the first two digits and the last two. The first two digits become your our part and the last two digits become you minute part. Once you have done this, run your validations on both the hour parts for them to be in the range of 0-23 and in the same way run your validation on both the minute parts for them to be in the range of 0-59.

For calculating the difference in time you can do this :
Find out the larger of the two time quantities, this can be done by comparing the hour part and if hours are equal then comparing the mimute part. Once you have the larger of the two time quantities, there are three possibilities - 1. the minute part of the larger time quantity is greater than the minute part of the smaller time quantity, 2. the minute part of the larger time quantity is equal to the minute part of the smaller time quantity and 3. the minute part of the larger time quantity is lesser than the minute part of the smaller time quantity.
In the first case the time difference is calculated this way : subtract the smaller time quantity's hour part from the larger time quantity's hour part and then do the same for the minute part. The answer is your difference. In the second case, since the minute part is equal just subtract the …

verruckt24 438 Posting Shark

Yes I am sure many people around here know how to write those methods, but we won't just give them to you for free, at the most we can offer you a pseudocode for these, but then since these sorting techniques are quite popular you can find an algorithm for them on the net or in a DS book quite easily. When you have done that and if you have any specific problems, you can post and we will help you.

EDIT : Also since these questions have been asked and answered on the forum many times over, searching the forum for similar threads would also provide needed information.

verruckt24 438 Posting Shark

There is not much common where purpose of usage is considered for Java and JavaScript though I am sure they share together much history.

Java is a general purpose language for programming client or server side applications. JavaScript on the other hand is a client-side scripting language.

Since you mention you are a beginner siting and example based on usage would make tings a little clearer I guess. Java would most likely be used for developing applications that run on a stand alone PC such as a desktop GUI program. If you are aware of file sharing peer-to-peer applications, LimeWire is one of them. Java is also used to develop applications that run on the server, such applications normally run without much user interaction and continue to run for days or even months on end without being stopped even once. Various services offered by companies to their clients e.g. messaging service fall in this category. These applications are often called command-line based applications as they are started by commands on the command shell.
JavaScript is used to carry out client side programming in web applications. JavaScript code is embedded within HTML pages and runs in the context of the browser. Most web browsers today have built-in support for JavaScript. JavaScript is commonly used for validating informatoin filled out in web forms, though it does have other uses.
Google about both of them for further information.

verruckt24 438 Posting Shark

Hi Puneet,
I haven't gone through your ORM framework, I need sometime for that, but on first thoughts I would like to suggest you another very popular ORM framework - Hibernate - which you might have heard of. This is a project similar to what you have started. Since you talk about adding features to your framewor, going through this you would be able to know a lot of features that a full production release of such a system might have and then deduce a set of core features that you need to have in such a framework/system.