|
for this line of code:
this line sets the properties for sending mail.
like u can put smtp.gmail.com (set host)for sending mail from gmail account.. and second argument is for port
for gmail 587/465
default port is 25/26.
got it ?
you can ask me for more information
|
|
|
|
|
Hi,
i have developed a Java program to convert an infix expression into a postfix expression but in output i am getting null. Below is my program . There is some conceptual mistake but i am unable to find it out. please help me...
import java.util.Stack;
public class infixToPostfix{
private int index;
private char ch;
private char lparenthesis='(';
private char rparenthesis=')';
Stack stack=new Stack();
private String output="";
public boolean isOperator(char op){
if(op == '^' || op == '*' ||op == '/' || op == '%' || op == '+' || op == '-')return true;
else return false;
}
public boolean isOperand(char opr){
if(opr >= 'A' && opr <='Z')return true;
else if(opr >= 'a' && opr <= 'z')return true;
else return false;
}
public int getPrecedence(char c){
switch(c){
case '(': case ')': return 5;
case '^':return 4;
case '*': case '/': case '%': return 3;
case '+': case '-': return 2;
}return 0;
}
public String getPostfix(String expr){
stack.push('(');
for(index=0;index<expr.length();index++){
ch=expr.charAt(index);
if(isOperand(ch)){
output=output+ch;
}
else if(ch == lparenthesis){
stack.push(lparenthesis);
}
else if(isOperator(ch)){
Object pop=stack.pop();
char ch1=pop.toString().charAt(0);
while(getPrecedence(ch1) >= getPrecedence(ch) ){
if(!stack.empty())stack.pop();
else break;
if(isOperator(ch1)){
output=output+ch1;
}
}stack.push(ch);
}
else if(ch == rparenthesis){
while(stack.pop().toString().charAt(0) != lparenthesis){
if(isOperator(stack.pop().toString().charAt(0)))
output=output+stack.pop();
}
}
else {
System.out.print("error.");
}
}
stack.clear();
return output;
}
}
modified on Saturday, January 29, 2011 1:19 AM
|
|
|
|
|
Firstly could you please edit the above and place the code between <pre></pre> tags (not code) so it is correctly formatted. Secondly try and narrow down the problem to the method or block of code relevant to the error; don't just expect people to analyse all your code without having the background knowledge of what it is trying to do.
I must get a clever new signature for 2011.
|
|
|
|
|
hey, i have edited it.... please tell me where is the error....
|
|
|
|
|
WindowsVsLinux wrote: please tell me where is the error
I have no idea, it's your code; tell us where it goes wrong and what happens and we may be able to make some suggestions.
I must get a clever new signature for 2011.
|
|
|
|
|
WindowsVsLinux wrote: but in output i am getting null
That can only happen in an expression that actually does something with output.
You can debug this by putting a print BEFORE each assignment to output and printing ALL of the values that you use in the expression.
You use output 4 times.
1. private String output="";
2. output=output+ch;
3. output=output+ch1;
4. output=output+stack.pop();
1 cant be null.
2/3 would require that ch/ch1 are null. But both are char data types. And that data type cannot be null.
So that only leaves 4.
I can't be sure about what is happening with 4 but it certainly looks like you have a lot of pop() calls just before that. And since pop() removes the item on the stack I am not sure what you think is going into output.
|
|
|
|
|
Thank you very much..... i was also thinking about that point.... i should do stack.pop() till !stack.isEmpty() is true... but there is another condition also... each time precedence should be checked... how can i do this....???
|
|
|
|
|
I don't understand the question.
However if you need to pop a value and do several checks on that value then you pop the value into a variable and then do the checks on the variable.
|
|
|
|
|
Hi,
I am looking to add a PDF markup/comments functionality on my website.
I've looked into ConceptShare http://www.conceptshare.com/[^] , WebProof....which are tools that can be integrated with my website except they are tooo expensive.
Are there any other options?
|
|
|
|
|
Why have you posted this on the Java forum?
|
|
|
|
|
It needs to be plugged into an existing Java site
|
|
|
|
|
But it's still not a Java question. If you want some free software then try a Google search. There are a number of PDF libraries around that may do what you want.
I must get a clever new signature for 2011.
|
|
|
|
|
There are a few Java PDF libraries around but I don't know of any that have a browser/web component. I'm guessing some at least would work in an applet, if that is a viable option for you. You would have to research them a bit to find out capabilities, costs, etc.
Failing that I think that your best bet would be to post the question on the Web Development forum. People there may have some suggestions for tools which are not language-specific.
|
|
|
|
|
Hello,
I have a simple menu bar base on a ul li list with embedded hyperlinks.
<ul>
<li id="menuHome"><a href="index.html" onMouseOver="setMenu('menuHome')" >Home</a></li>
<li id="menuResults"><a href="results.htm">Results</a></li>
<li id="menuEvents"><a href="events.htm">Events</a></li>
</ul>
I have set the CSS properties such as
#menuHome {
background-color: #CCC;
color: #000;
}
#navleft ul {
list-style: none;
padding: 0;
margin: 0 0 5px 0 ;
text-align: left;
}
#navleft li {
margin: 5px 0;
line-height: 23px;
}
#navleft li a {
text-decoration: none;
padding-left: 9px;
display: block;
width: 140px;
}
My Java script is quite basic
function setMenu( id )
{
var e = document.getElementById(id);
e.style.backgroundColor = 0x666666;
e.style.color = 0xFFFFFF;
}
My goal is to basically have a vertical menu bar that can be used for multiple webpages, so that after the user clicks on it, it will change the background color and text to a different color, so that it is apparent which page the user is on.
(I realize that I'm using the mouse hover for testing, it stops the page from reloading every time I test it).
The problem that I am having, if my understanding is corrent is that the tag that I pass in the jave call is bond to the "li" element of the menu list, the background color changes quite fine, but, I can not seem to be able to access the color property of the "a href" tag to change the text from black to white.
using the e.style example above how would to "Cast it" to the a reference?
Thank you in advance.
|
|
|
|
|
This is a JavaScript or CSS question, not Java. I think you will get a better response in the correct forum.
I must get a clever new signature for 2011.
|
|
|
|
|
Thank you, direction is alway a good start
|
|
|
|
|
Hello i have 3 properties file consisting of information. Is it possible for me to add the information of 3 properties files into database and instead of getting properties from the properties file, i get the values from the database?
however i have no idea on how to start anyone could guide me?
|
|
|
|
|
Create a table to hold the data that is currently in the properties file (one table for each properties file is the easiest option).
Insert the data into the table.
Read the data using a SQL select statement.
Your table structure can be very simple: two columns, key, value.
That's basically it.
|
|
|
|
|
i am doing it in a .java file in netbeans however there is error when i try to connect to the database..
my profiles file includes the following as shown below:
<br />
yahoo=http:
google=http:
so i still use the key and value for my table?
modified on Monday, January 24, 2011 10:59 PM
|
|
|
|
|
pancakeleh wrote: however there is error when i try to connect to the database.
Maybe if you show what that error is people will be able to make some suggestions.
I must get a clever new signature for 2011.
|
|
|
|
|
Yes, you can pick up the value you want from the table with a sql command something like:
SELECT value FROM MyTable WHERE key = 'yahoo'
That would do it. NB, key may be a reserved keyword depending on the particular database you are using. Just give that column whatever name is convenient instead if that is the case.
As Richard has pointed out, if you let us know the problem you are having when you try to connect to the database we might be able to help a bit more.
|
|
|
|
|
|
WHICH ERRORS?
Do you actually have errors while running the code - I mean this red text running in that little fancy window below your code - you know? Is it to much to ask for copying it in here?
Otherwise we can just tell you that we're also sometimes "facing errors"
regards
Torsten
I never finish anyth...
|
|
|
|
|
Once again you seem to be trying to build an application line by line without spending some time reading the documentation and getting a grasp of the fundamentals. Take a look here[^] at the Java API documentation and check the requirements of the features you are trying to use.
I must get a clever new signature for 2011.
|
|
|
|
|
You are not handling the exceptions these JDBC methods throw. You should take some time to learn the basics of JDBC programming. There are plenty of good books available, and lots of on-line tutorials if you cannot afford a book.
|
|
|
|