Results 1 to 20 of 26
Thread: basic java
- 03-24-2009, 08:24 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 15
- Rep Power
- 0
- 03-24-2009, 09:39 PM #2
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
What's your problem/question?
btw... cut down on the exclamation and question marks...I die a little on the inside...
Every time I get shot.
- 03-25-2009, 02:55 AM #3
Member
- Join Date
- Mar 2009
- Posts
- 15
- Rep Power
- 0
classes
my doubt is!!!!
wats the use of wrapper classes in java???
- 03-25-2009, 11:31 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I can say it in this way.
Can you understand that.The wrapper classes are normal classes that extend the Object superclass
- 03-25-2009, 11:44 AM #5
Member
- Join Date
- Mar 2009
- Posts
- 15
- Rep Power
- 0
That i know that it extends the Object class!!!!
I am asking wats the use of Wrapper classes!!! i we ar making primitive data types as wrapper!!!
- 03-26-2009, 10:51 AM #6
Member
- Join Date
- Mar 2009
- Posts
- 13
- Rep Power
- 0
Hi vijay,
The concept of Wrapper classes is used to allow us to store primitives into collections. For example:
Suppose you wish to make a List of integers. In this you can use the corresponding wrapper class for integers i.e Integer to store the value of the your primitive integer.
<CODE>
List<Integer> vijayList= new ArrayList<Integer>();
</CODE>
Also wrapper classes can be used to parse primitive data values from a string . like
<CODE> int vijayInt = Integer.parseInt("123");</CODE>
I hope that suffice. For rest of the methods in the Wrapper classes you can refer to Java API documentation
- 03-27-2009, 11:10 PM #7
Member
- Join Date
- Mar 2009
- Posts
- 15
- Rep Power
- 0
thanks i have one more doubt!!!
import java.util.Scanner;
class ScanNext {
public static void main(String [] args) {
boolean b2, b;
int i;
String s, hits = " ";
Scanner s1 = new Scanner(args[0]);
Scanner s2 = new Scanner(args[0]);
while(b = s1.hasNext()) {
s = s1.next(); hits += "s";
}
while(b = s2.hasNext()) {
if (s2.hasNextInt()) {
i = s2.nextInt(); hits += "i";
} else if (s2.hasNextBoolean()) {
b2 = s2.nextBoolean(); hits += "b";
} else {
s2.next(); hits += "s2";
}
}
System.out.println("hits " + hits);
}
}
If this program is invoked with
% java ScanNext "1 true 34 hi"
it produces
hits ssssibis2
how this works!!!! how we got this as output!!! pls explain!!
- 03-28-2009, 01:39 AM #8
Vijay... you really should learn to communicate correctly when writing in the forum:
- Stop putting so many exclamation marks (!!!) after your sentences. It seems like you are demanding attention and it could be misunderstood and people will get angry or just ignore you.
- ALso, give your variable names some meaning... s, s2, etc... doesn't mean much and is confusing. Try str1, str2, intg, bool, etc... or something like that for names.
- If I read your program correctly, it's working as you programed it. Try to debug it... just follow the your code and you will find out why you got that output (hint: look at what the while loops are doing)
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 03-28-2009, 05:18 AM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Thumbs up Chris for you. I really looking into about naming conventions of variables in that code. Really hard to get an idea what's going on. Chris I guess lots of members who are trying to give an answer, are not run the code. Just go through the code and try to find where the error is. I do that most of the time. So naming variable in meaningful way is must.
- 03-28-2009, 07:34 PM #10
Member
- Join Date
- Mar 2009
- Posts
- 15
- Rep Power
- 0
ya sure!!!!
- 03-28-2009, 07:51 PM #11
Member
- Join Date
- Mar 2009
- Posts
- 6
- Rep Power
- 0
many people have already asked to STOP PUTTING EXCLAMATION MARKS .. the variables you have named make it confusing to explain it
-
Agrees with others above. Vijay, could you tone it down a bit?
- 03-28-2009, 10:09 PM #13
Member
- Join Date
- Mar 2009
- Posts
- 15
- Rep Power
- 0
what is the use of making strings in java as immutable?
- 03-28-2009, 10:29 PM #14
Member
- Join Date
- Mar 2009
- Posts
- 15
- Rep Power
- 0
one more doubt ,why is String class in java marked as final?
- 03-28-2009, 11:29 PM #15
Strings and more strings
Answers are probably in this link:
String (Java Platform SE 6)
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 03-29-2009, 12:43 AM #16
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
wrapper/final/immutable...
These questions are getting at Java (and I would guess other language) syntax and idiom (usage). I would recommend reading a textbook - or Wikipedia which is often good at supplying an overview.
Googleing it for you reveals Wrapper_class and Final_(Java). Both articles are full of references to allied topics. If nothing else they should provide you with some way of framing a specific question - whether some specific opinion of yours is correct, what the meaning of some specific assertion is etc.
- 04-03-2009, 03:00 AM #17
Member
- Join Date
- Mar 2009
- Posts
- 15
- Rep Power
- 0
What is serialization? can anyone give a good example to explain that?
- 04-03-2009, 04:15 AM #18
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You are asking questions in a hurry. Did you read anything before ask questions like this? Just like this, you cannot learn Java anyway. You must read more about theories in Java and do some examples.
- 04-03-2009, 01:32 PM #19
Yeah... asking and asking and absolutely no thanks for the answers so far. The OP's 'tude is quite demanding.
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 04-03-2009, 02:51 PM #20
Member
- Join Date
- Aug 2008
- Location
- The Netherlands
- Posts
- 25
- Rep Power
- 0
Similar Threads
-
Basic Java help, AIM?
By jkswebsite in forum New To JavaReplies: 4Last Post: 07-11-2012, 06:17 PM -
need very basic help with xml parsing in java
By 2potatocakes in forum New To JavaReplies: 7Last Post: 09-17-2008, 12:22 PM -
basic java help
By adred in forum New To JavaReplies: 0Last Post: 03-08-2008, 12:36 PM -
Help with basic shapes in java
By carl in forum Java 2DReplies: 1Last Post: 07-31-2007, 11:40 PM -
Help, basic shapes using java
By coco in forum AWT / SwingReplies: 1Last Post: 07-31-2007, 08:52 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks