Results 1 to 5 of 5
Thread: VeryLong Integer.. help
- 12-14-2007, 03:06 AM #1
Member
- Join Date
- Dec 2007
- Posts
- 21
- Rep Power
- 0
VeryLong Integer.. help
Hi guys,
please, help me))) :confused:
I am trying to create a VEreyLong Integer class.. I am using ArrayList..
but I have some questions..
this is my code (just the beginning)
Java Code:package VeryLong; import java.util.*; public class VeryLong{ public VeryLong(ArrayList<Integer> a){ ArrayList<Integer> verylong = new ArrayList<Integer>(); System.out.println("number is created"); }; public ArrayList<Integer> Readln(){ int i=0, tempint=0; ArrayList<Integer> verylong = new ArrayList<Integer>(); Scanner in = new Scanner(System.in); String str; str=in.next(); while (Character.isDigit(str.charAt(i))) { tempint = Integer.parseInt( Character.toString( str.charAt(i) ) ); verylong.add(tempint); i++; }; return verylong; } }
VeryLong extends ArrayList???? But in this case, how do I block other ArrayList methods, which I don't need..
I know, that it sounds really confusing.. but please, help me!!!))) :confused: :confused: :confused:
- 12-14-2007, 03:16 PM #2
I think what you want to do is make the ArrayList a field in your class.
Java Code:package VeryLong; import java.util.*; public class VeryLong{ private ArrayList<Integer> longInt; public VeryLong(ArrayList<Integer> a){ this.longInt = a; System.out.println("number is created"); }; public ArrayList<Integer> Readln(){ int i=0, tempint=0; Scanner in = new Scanner(System.in); String str; str=in.next(); while (Character.isDigit(str.charAt(i))) { tempint = Integer.parseInt( Character.toString( str.charAt(i) ) ); this.longInt.add(tempint); i++; }; return this.longInt; } }
- 12-14-2007, 03:30 PM #3
Member
- Join Date
- Dec 2007
- Posts
- 21
- Rep Power
- 0
em.. So, in that way, longInt will be my very long integer itself.. right? Thank you so much.! I still don't understand it completely, but I think I am on the right way.)))
- 12-14-2007, 09:28 PM #4
Member
- Join Date
- Dec 2007
- Posts
- 21
- Rep Power
- 0
I am sorry for the stupid questions, but how can I test it?
This is what I have:
Java Code:import VeryLong.VeryLong; import java.util.*; class main{ public static void main(String[] args){ VeryLong.Readln(); } }
Thanks a lot!!!
- 12-14-2007, 09:48 PM #5
You need to create a VeryLong object.
Java Code:VeryLong vl = new VeryLong(**Some array list here**);
Java Code:pucbli VeryLong(){ this.longInt = new ArrayList<Integer>(); }
Java Code:VeryLong vl = new VeryLong();
Java Code:vl.Readln() //by the way, it is a good idea to start your method names with lower case letters
Similar Threads
-
Breaking down an integer
By Emily in forum New To JavaReplies: 1Last Post: 03-06-2008, 06:39 PM -
Create a VeryLong class that will store an integer of arbitrary length.
By hey in forum New To JavaReplies: 2Last Post: 12-12-2007, 05:01 PM -
Short/Integer
By mew in forum New To JavaReplies: 3Last Post: 12-06-2007, 09:28 PM -
Integer vs int
By bugger in forum New To JavaReplies: 1Last Post: 11-14-2007, 09:13 PM -
Help with Integer in java
By susan in forum New To JavaReplies: 1Last Post: 07-14-2007, 05:25 AM
Bookmarks