|
Basically, the keyword new is to initialize a new object. If you need to create an object, you would use the new keyword to initialize the object such as, Car myCar = new Car(). This creates a new Car object which is then assigned the variable name myCar. Here is a link to java's tutorial page to find some more examples and more information about the keyword new.
|
|
|
|
|
To expand on this example and tie in the idea of an "instance" of an object:
CCarClass *myCar = new CCarClass();
CCarClass *sisterCar = new CCarClass();
This would create two specific and individual instances of the class, each its own object, on the heap (as opposed to the stack). They will persist until you delete them (which in C++ you must do yourself to clean up resources).
delete myCar;
delete sisterCar;
|
|
|
|
|
Albert Holguin wrote: They will persist until you delete them (which in C++ you must do
yourself to clean up resources).
In java of course you do not delete them.
They are cleaned by the garbage collector when there are no more active references to them.
|
|
|
|
|
lol... didn't realize this was posted in the java forum... my bad! assumed C++
|
|
|
|
|
Just to add to that , the new keyword basically allocated memory location for the object to be stored. if we simply create a object variable we are simple creating a handle to access that memory location and when we use new we alocate memory
so in the above example myCar is the handle to memory location assigned by new Car();
|
|
|
|
|
When used in an expression it results in the following
1. Creation of a instance of a class
2. Initialization of that class instance into a known state.
3. Returns a reference to that instance.
There might be other results as well but the above is probably sufficient.
|
|
|
|
|
hi
I have CCNA certificate .
I want get name of all interfaces in one cisco router(AS 5300) with use SNMP protocol in java.
may give me any reference or source code for this purpose .
please help me.
|
|
|
|
|
I think it is likely that you will get more information from the technical manuals (or support site) of the Cisco router. This is not really a Java question.
I must get a clever new signature for 2011.
|
|
|
|
|
ok so im just starting the sun certified java associate course...just wanna know if the certification is worth much along with the different levels it offers.
|
|
|
|
|
Only if you need it to get a job.
I must get a clever new signature for 2011.
|
|
|
|
|
Difficult to say definitively. Some employers place a lot of weight on having certification, some think it adds no value at all.
I think that if you are planning to work as a contractor or "coder for hire" then this is worth having as it can show a commitment to your professional skills development and a certain basic level of competence. If you are looking for a long-term permanent job then its value is more questionable. In those cases, people will probably be more interested in your actual experience and how relevant it is to the role they are seeking to fill.
|
|
|
|
|
It add some additional and valuable weight in your Profile as well as in your CV. infact It would also gives a brand value to your resume which will help you in getting good pay and job.
|
|
|
|
|
Hi!
i'm having problems setting the position of the dialog (Left and Top) after i have created it.
i have tried this, but it's not working.
$('#dialog').dialog('widget').position().left = 200;
i have tried different solutions i have found but they didn't work either.
could someone help
i want to move the dialog to left and top cordinates i have stored i 2 variables
thanks.
|
|
|
|
|
found it it should be
$('#dialog').dialog({ position: [x,y])}
edit: you also need to convert to x,y variable to int with parseInt(x)
modified on Tuesday, March 1, 2011 8:40 AM
|
|
|
|
|
HELP me! how connec from java to MS SQL Server? where put the driver? and some examples, please!!!
Thanks!!
modified on Sunday, March 6, 2011 3:24 PM
|
|
|
|
|
You will probably want to use JDBC[^] which does most of the hard work for you.
I must get a clever new signature for 2011.
|
|
|
|
|
|
i olreadu used Link-1, but i have a new problem, when i write connection string from Netbeans to MS SQL Server 2005, like this:
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://STAR2\\TESTGENSERVER\\TESTGENSERVER:1433;databaseName=Katalog_tovarov","name user(windows)","password(in windows)");
PreparedStatement pps = con.prepareStatement("select * from [KHAI-6-Grushko].[dbo].[User]");
ResultSet rs = pps.executeQuery();
while(rs.next()){
//do something
System.out.println(rs.getString("FirstName"));
}
con.close();
}catch(Exception e){System.out.println("error "+ e.getMessage());
}
and i have error messaage : can not connect to server with port 1433.. what i need to do?
|
|
|
|
|
May be like this +- sory if iam wrong...
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBConnection {
private Connection koneksi;
public Connection connect(){
//for connection to driver
try{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("success load driver");
}catch(ClassNotFoundException cnfe){
System.out.println("not use Driver "+cnfe);
}
//for connection to database
try{
String url="jdbc:mysql://localhost:3306/data";
koneksi=DriverManager.getConnection(url,"root","");
System.out.println("connection succes");
}catch(SQLException se){
System.out.println("Failed connection "+se);
//JOptionPane.showMessageDialog(null,"Failed connection...MySQL server belum aktif");
}
return koneksi;
}
}
|
|
|
|
|
i need not mYsql i need mSsql, but thank you)
|
|
|
|
|
Hi,
I've an assignment to make a program that should generate all the permutations of a string one by one. I know many algorithm of generating permutations using recursion, but question has asked to generate it one by one. So deliverable should contain a class called "PermutationIterator" which should have a method "hasNextPermutation" and "nextPermutation". They have given one hint, make a "tailIterator" object of type "PermutationIterator" inside a "PermutationIterator" class (like a node of LinkedList) and then do some funny things with it. I can't figure out where should I start....any help would be appreciated.
Note: You can't generate all permutations at one time, then store it into an array and then call each of them one by one. Please don not suggest this way.
Thank you
Shivam Kalra
|
|
|
|
|
Take a look here[^] for some sample code that will help you.
I must get a clever new signature for 2011.
|
|
|
|
|
hi..
check the following code..
<script type="text/javascript">
var indMoney = function (v)
{
v = (Math.round((v - 0) * 100)) / 100;
v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
v = String(v);
var ps = v.split('.'),
whole = ps[0],
sub = ps[1] ? '.' + ps[1] : '.00',
r = /(\d+)(\d{3})/;
while (r.test(whole))
{
whole = whole.replace(r, '$1' + ',' + '$2');
}
v = whole + sub;
return v;
}
</script>
The result of the above function is displaying like this 123,123,123.00
but i want in this format 12,31,23,123.00 i.e indian currency format..
|
|
|
|
|
This is the Java forum, Javascript is next one down.
I must get a clever new signature for 2011.
|
|
|
|
|
More than that he has asked the same question in the Questions section too...lol
|
|
|
|