It's pretty long and hard to follow, buddy. And, if you need us to help you solve the probs that you've got, then that means you need to be explicit about your question.
It's pretty long and hard to follow, buddy. And, if you need us to help you solve the probs that you've got, then that means you need to be explicit about your question.
Well, why don't you put the text "Lorem ipsum" and the date in one div. For example,
<div id="pdate">Lorem ipsum- 14 Jan 2011</div>
Shouldn't that fix the problem?
A quick tutorial on how to do such a task like this will be appreciated. Is there a site that has a tutorial on this?
Hmmm, it's quite long to follow. Select the lines you have probs with so we can help you. And if we need to look at the entire code for more info, it's still there.
Cheers,
Try changing the code in your HTML file to
<div class="button">Button</div>
and in your CSS file,
.button{ }
Otherwise, follow what hericles has mentioned above to fix your problem.
I think a simple Javascript code will get you a solution that you want. Hint: give it an id and use getElementById in Javascript if you want to solve the problem by using Javascript.
Well, since the task's is a piece of cake, You can also achieve what you want in CSS 1,2 or 3.
<h1 [U]class="title"[/U] >The Title</h1>
In your CSS,
.title:hover { color: BLUE; }
I hope this helps you.
Try changing the atrribute's place. For example,
<input type="image" src="image.jpg" onclick="func('hello')" />
Is the image showing? Is it in the same directory as your HTML file/files?
Thanks for the explanation.
Nice example. OK.Now, Would you call the method getInstance inside the constructor so when the constructor gets called then it will give an instance of ConnectionManager class? OR Would you call the method in another class?
And, What do constructors normally do? Checking and validation? and what else?
Thanks.
I hope there is no offense. The solution to the exercise that you posted DOES NOT make sense really. If you're using a class which you don't really need, Why are you using in the first place? Well, if you didn't have the Connection class, you'd have to make an array of ConnectionManager objects like I previously did.
And the variable iCount has the deafult value which is ZERO. Therefore, your if-statement will evaluate to true all the time, won't it? and also, I can see any calls to the method getNewConnection in your constructor in order for it to change the value of iCount. Please do correct me if I'm mistaken.
public Connection getNewConnection(){
if(iCount < myPrivateConnections.length){ [B][U] <-----< Here. iCount == 0 [/U][/B]
//give an available connection
return myPrivateConnections[iCount++];
}
return null;
}
I know the solution I came up with before is not dynamic. But, Is there anything wrong with it?
ok if i change thelanguage and ask it for c++ ...do i ill be allowed doing so.
I am not sure about c++. Obviously, you've asked the wrong person and we are not in the c++ forum. You could ask the c++ people so they will answer your question with a definite answer. Are you trying to program in java or C or C++?
By the way, each of the languages has its own section on the website.
Good luck,
If you give an object in stead of a String in a method, the object's toString() method is called.
In your example, this is happening in the line
System.out.println(b); // You pass an object instead of a String
.
What really is executed:System.out.println(b.toString());
I know for sure. it is happening on this line.
System.out.println(b);
More about the fact that I was wondering why it is happening. it's because of method overriding. Thanks all again.
adding to what hiddepolen said: The toString() method, overrides the actual java toString() method, thats why its name cannot be changed... here is a bit on overridden methods:http://docs.oracle.com/javase/tutorial/java/IandI/override.html.
Aha !! Now, I know why. I never thought of method overriding. Thanks all for the replies.
thanks for the reply...... bt sir if i have to pass in such a way than...my prpose is not getting solve actualy...i.e passing if statement any condition as funtion's argument. why cant i>j can be pass as string??
Do you mean that you want to pass this i>j as a string argument in a method? If yes so, then yes you can and the result you'll get out of it is that "i>j" which doesn't compare i to j. Here is an example that might hopefully be useful in your case,
public static void compareMe(){
int x =0;
int y =3;
System.out.println( ((x >= y) ? x:y) );
// This line says if x >= y, then println x else println y.
}
Incase of java , yes you can ....(possible in other languages also)
but remember...you can pass only variables but not the logic ..
i meanvoid dothis(String s) { if(s) { -----
if you call the dothis as dothis("10>5"); ..It is not correct
you can pass the values i.e 10 , 5 but not the logic(i mean 10>5)
because.. if condition will accept only boolean result..
if(condition) ---- the condition should always evaluate to boolean value in java
Since you're passing a String Object to your method doThis(String s), the argument "10>5" is perfectly fine. However, it is not treated as a logical operator. It's just gonna be "10>5" and nothing more or less.
can we pass condition of if statement as an argument in any language?????????
The original question is about whether you're ALLOWED to pass an if-statement in the args which is not acceptable in Java. I agree that you can pass your condition in a for-loop after you initialise your variable and that is fine.
I was just wondering why the constructor makes a call to the method toString() then I have realised that it's because of the method's name. And why is its name so unique? I changed the name but I don't get the same results. Anyone could possible explain this please? Thanks.
public class Bath {
private String // Initialising at point of definition
s1 = "Happy",
s2 = "Happy",
s3, s4;
private Soap castille;
private int i;
private float toy;
private String eid= "Eid";
public Bath(){
System.out.println("Inside Bath()");
s3 = "Joy";
toy = 3.04f;
castille = new Soap();
}
// Instance initialization
{ i = 47;}
public String toString(){
if(s4 == null) //delayed initialistion
s4= " Joy";
return
"s1 =" + s1 + "\n" +
"s2 =" + s2 + "\n" +
"s3 =" + s3 + "\n" +
"s4 =" + s4 + "\n" +
"i =" + i + "\n" +
"toy =" + toy + "\n" +
"castille =" + castille + "\n";
}
public static void main(String[] args){
Bath b = new Bath();
System.out.println(b);
}
I guess that is possible, but what language are you programming in? Tiny detail :)
Hmm, as far as programming in java practice is concerned, I think you will get a compile error if you try doing something like this
int i=0;
public static void makeCake(if i > 0, )
{
}
Therefore, the answer is No, you can't. I'd be surprised if you could do that.
@Philippe.... Is that what you're trying to tell me in your post?
The fields should look like these?
static ConnectionManager[] connecter = new ConnectionManager[5];
static int i=0;
And then, I loop through the connection objs in the array inside my method?
I ain't sure how to create connection objects from Array. The below code is working for me.
Fields as follows:
static Object[] connecter = new Object[5];
static int i=0;
static ConnectionManager connecter(){
if(ConnectionManager.i <= connecter.length){
return new ConnectionManager();
}else if(ConnectionManager.i > connecter.length){
return null;
}
return null;
}
Hi everyone,
I'm trying to do exercise from the book I'm reading at the moment. But, I don't seem to have understood the last part of the question. I'd greatly appreciate anyone explaining the question to me. I have done all parts of the question except the last one which I am not really sure of. The bold lines that I don't really understand.
I don't want any answers please. I'd like to solve the problem myself after having a good understanding of what I should be doing and someone explains the part that I don't understand.
Here is the question:
Exercise 8: (4) Following the form of the example Lunch.java, create a class called ConnectionManager that manages a fixed array of Connection objects. The client programmer must not be able to explicitly create Connection objects, but can only get them via a static method in ConnectionManager. When the ConnectionManager runs out of objects, it returns a null reference. Test the classes in main( ).
// Class called Soup1
class Soup1 {
private Soup1(){ }
public static Soup1 makeSoup(){
return new Soup1();
}
}
// Class called Soup2
class Soup2 {
private Soup2(){ }
private static Soup2 ps1 = new Soup2();
public static Soup2 access(){
return ps1;
}
public void f(){ }
}
// Class called lunch
public class lunch {
void testStatic(){
Soup1 soup = Soup1.makeSoup();
}
void testSingleton(){
Soup2.access().f();
}
}
// Class called ConnectionManager
class ConnectionManager {
Object[] connecter = new …
PROBLEM IS FINALLY SOLVED. Just would like to make this thread useful for others who perhaps have the same or even similar problem to mine.
I could access the local server by using the local IP address. For the server to give me access just by using http://localhost or even more sensible names such as MyName.com or whatever name I want to use.
I opened this file and changed a few things. The file is C:\Windows\System32\drivers\etc\hosts.
I added my local IP address then followed by a name like localhost or rotten69.com or whatever name you'd like to use.
Eventually, you will have something like this: 124.44.00 localhost or 124.44.00 rotten69.com
NOTE: DO NOT ADD # at the beginning of the line.
That is what Apache gives in the access log text file.
::1 - - [19/Jan/2012:21:53:49 +1000] "GET / HTTP/1.1" 403 202
::1 - - [19/Jan/2012:21:58:03 +1000] "GET / HTTP/1.1" 403 202
That is only when I'm trying to access the server using localhost in the URL bar
I solved the problem. Now, I do have access to the local server by using the IP address. But, I can't access it by using http://localhost
Here is what I have in the httpd.conf
<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from (THE IP ADDRESS(numeric value))
</Directory>
Cheers,
If yes so, please do tell me what they should be.
Or it may be an environment set-up problem. Do I need to configure the path and environment variables?
@smantscheff... Yeah, I did mate. Hmmm, Where do I find the error log ? Is that on their site or in one of the apache files on my machine?
Cheers,
The error message is from Apache, it has nothing to do with MySQL. Look in your apache configuration file (httpd.conf) and in the local directory's .htaccess files for access restrictions.
None of those files were touched before I wasn't given access to the local server. I don't know what exactly needs to be changed in the files in order for the server to get working as normal. I also don't want to stuff everthing up by changing directories in the files.
Before I seek help, I changed the lines between <directory> tags where the DenyAllow command is. Then, I had to get them to default settings as it hasn't fixed the problem.
Any help please on how to fix the issue?
Cheers,
Hi everyone,
I had this problem with phpMyAdmin and successfully fixed it. Then, after some days, I encountered the access problem with the WAMP server. I haven't changed anything yet. Or maybe, I need to set up the environment variables?
The message I'm getting is that
Forbidden
You don't have permission to access / on this server.
I searched for some solutions on the web but I couldn't be bothered to keep searching(REALLY Lame!!). Well, no. I wasted enough time on searching for a solution. You guys are AWESOME and some of you may know what might be causing the problem.
Hear from you, Folks.
Well, we can't see line 166 in the previous post. Did you post all the code you've got or you actually have a problem with?
Cheers,
Have an auto-increement ID in both tables. And the one in students table should be a primary key so you will have it as a foreign key in the English table. That way you're making a connection between both tables. Otherwise, you can do vice-versa. You can use the student name(easy to follow and track) as a foreign key in the English table as well. But, This would depend on what your keys are.
I hope this helps you a bit.
Well, I would like to mark the thread as solved so the other person will get +1. But, I think that is not worth it at present because I found out the answers by myself.
Did you check the API?
I have found some good explanations so now I know why it formats the number after three decimal places. it's because "%, .3" which means put a comma after three decimal places and if I wanna add minus, I only need to use "%+". So, if the number being formatted is a minus number then the formatter will add the sign to it.
I hope this helps whoever looks up this information. Unfortunately, It seems like some people know the answers to these questions but they tend not to give them away. Gosh, it'd cost heaps and heaps of time and effort to explain them to beginners like me. Lol
Brilliant Question!!! Yes, I did. Actually, that is the website I was on.
G'day everyone,
I'm doing at a tutorial on Oracle website and still following it so far. I have come across this formatter "%,8d" and can't seem to work out how it works. I know it's adding a coma to the integral number. The thing that I can get my head around is the decimal place isn't specified. I wonder how the compiler knows where to put the comma?
The last line is used to add a plus sign. Well, what If I wanna add a minus sign?????
"%-" that didn't work for me.
long n = 461012;
// --> " 461,012"
System.out.format("%,8d%n", n);
// --> "+461,012"
System.out.format("%+,8d%n%n", n);
Thanks,folks.
Hi everyone,
I'm using jquery in this piece of script and also trying to call the functions. But, they aren't working at ALL and the firefug is saying that there is an error in the script. The error is
missing ) in parenthetical
[Break On This Error]$.post('ajax/like_add.php', (article_id:article_id), function(data){
and the firebug points to the colon.
This is the entire piece of script that has both functions.
function like_add(article_id){
$.post('ajax/like_add.php', (article_id:article_id), function(data){
if(data == 'success'){
like_get(article_id);
}else{
alert(data);
}
});
}
function like_get(article_id){
$.post('ajax/like_get.php',(article_id:article_id), function(data){
$('#article_'+article_id+'_likes').text(data);
});
}
Thanks, folks.
I created the foreign key on article_id. But, I couldn't specify this property at the time of creation. ON UPDATE CASCADE.
I don't want to recreate the FKs. I just want to modify them to add these properties in ON DELETE SET NULL and so on. Is there a modify-constraint statement?
Thanks for explainin that to me. Now, I created the foreign keys that I needed for the tables. However, I was unable to add/specify restriction on the keys. ON UPDATE CASCADE ON DELETE SET NULL .. I don't know why mysql isn't happy to accept my commands.
From line 11 to 14, Would that be problematic to have all these SQL statements on just one line? (that is what I initially had)
What does this line mean? AUTO_INCREMENT=12?
I'm not sure how you recreated your database, but if you did it with an sql dump,
I dropped all constraints and FKs from the tables and then dropped the database.
DROP DATABASE database_name
I noticed that this command is disabled when the DB has tables in it. So, I had to drop all tables then drop the DB.
Yes, I do have another table called articles. Therefore, mySQL server shouldn't refuse my request.
I personally don't see anything wrong with the syntax or the foreign keys that I am trying to make. Can you pick any error in the create statement?
Thanks, pal.
ID is a primary key in the parent table and causes a referential integrity issue if I attempt to delete it and recreate it.
Failed and Passed are both ints. What does the %n mean then? why is it used after failed=%d?
It doesn't mean a new line,does it? New line is \n.
I'm trying to make a table and mysql is giving me this error:
#1005 - Can't create table 'likes.users' (errno: 150)
That would be great to see a website that explains mysql errors like this for oracle http://ora-code.com/
CREATE TABLE IF NOT EXISTS `users` (
`user_id` int(2) NOT NULL AUTO_INCREMENT,
`username` varchar(20) NOT NULL,
`article_id` int(11) NOT NULL,
PRIMARY KEY (`user_id`),
CONSTRAINT `fk_article_id` FOREIGN KEY (`article_id`) REFERENCES `articles` (`article_id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1
I can't see anything wrong with the create statement.
Hi everyone,
I have created tables and deleted some rows and then inserted new rows. The IDs of the later created rows didn't start at 0 or 1. I dropped my entire database then recreated the same one with the same tables and fields. Unfortunately, newly entered rows started from where they were left at. For example, in the previous database, I had 9 rows in users table. After the database creation, the first row started at 10 instead of starting at 0 or 1. Now, I'd like to reset the auto-increment ID. Is there a way of resetting the ID after dropping and recreating a table with the same fields ?
I tried this line but it didn't work !!
ALTER TABLE `users` AUTO_INCREMENT = 1;
Thanks, folks.
Correction to the earlier post. The example was NOT from the book I was reading. It was actually from Oracle website. I was lookin' at an example of varags.
Thanks guys for the links. But, I still don't know how this line "passed=%d; failed=%d%n" works. What do the format specifiers(like thines01 said) do?
Hi all there,
I was reading a book on Java and came across this piece of code. Now, I am not sure how line 13 works especially, these symbols after the equal signs "passed=%d; failed=%d%n" . How do the symbols affect the output of the variables(passed & failed)? so let's say they are left out, then we won't get any values printed out.
What are they called? Are they operators or something like that? Any link you'd share that has a list of them?
Anyone has a minute or two to explain that to me? Thanks in advance.
int passed = 0;
int failed = 0;
for (String className : args) {
try {
Class c = Class.forName(className);
c.getMethod("test").invoke(c.newInstance());
passed++;
} catch (Exception ex) {
System.out.printf("%s failed: %s%n", className, ex);
failed++;
}
}
System.out.printf("passed=%d; failed=%d%n", passed, failed);
After I changed the directory in the file 'alias/phpmyadmin.conf', the WAMP allows me to use phpMyAdmin now. But, I still don't know why it stopped giving me access before.