Abbey Samuel

Greenhorn
+ Follow
since May 02, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Abbey Samuel

//: appendixa:MutableInteger.java
// A changeable wrapper class.
import com.bruceeckel.simpletest.*;
import java.util.*;

class IntValue {
private int n;
public IntValue(int x) { n = x; }
public int getValue() { return n; }
public void setValue(int n) { this.n = n; }
public void increment() { n++; }
public String toString() { return Integer.toString(n); }
}

public class MutableInteger {
private static Test monitor = new Test();
public static void main(String[] args) {
List v = new ArrayList();
for(int i = 0; i < 10; i++)
v.add(new IntValue(i));
System.out.println(v);
for(int i = 0; i < v.size(); i++)
((IntValue)v.get(i)).increment();
System.out.println(v);
monitor.expect(new String[] {
"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]",
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
});
}
} ///:~

Actually I have the bruceeckel source code in My Document and also the Java Documentation in the same My Document and each time I try to import from the Java documentation the program gets compiled while the import com.bruceeckel refuses to compile.I think may be this has to do with my classpath or path which I did not set right this is the classpath I set please help me to know how to access this
CLASSPATH:C:\MyJavaLib;C:\MyJavaLib\myutils.jar;C:\MyJavaLib\blackboxclasses.jar;
C:\Documents and Settings\User\My Documents\IntValue.java:15: class MutableInteger is public, should be declared in a file named MutableInteger.java
public class MutableInteger {
^
C:\Documents and Settings\User\My Documents\IntValue.java:3: package com.bruceeckel.simpletest does not exist
import com.bruceeckel.simpletest.*;
^
C:\Documents and Settings\User\My Documents\IntValue.java:16: cannot find symbol
symbol : class Test
location: class MutableInteger
private static Test monitor = new Test();
^
C:\Documents and Settings\User\My Documents\IntValue.java:16: cannot find symbol
symbol : class Test
location: class MutableInteger
private static Test monitor = new Test();
^
Note: C:\Documents and Settings\User\My Documents\IntValue.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors

Tool completed with exit code 1
17 years ago
Vyas try and comply it cost you nothing to update this information
17 years ago
This is the code and the error it throws up



//: appendixa:MutableInteger.java
// A changeable wrapper class.
import com.bruceeckel.simpletest.*;
import java.util.*;

class IntValue {
private int n;
public IntValue(int x) { n = x; }
public int getValue() { return n; }
public void setValue(int n) { this.n = n; }
public void increment() { n++; }
public String toString() { return Integer.toString(n); }
}

public class MutableInteger {
private static Test monitor = new Test();
public static void main(String[] args) {
List v = new ArrayList();
for(int i = 0; i < 10; i++)
v.add(new IntValue(i));
System.out.println(v);
for(int i = 0; i < v.size(); i++)
((IntValue)v.get(i)).increment();
System.out.println(v);
monitor.expect(new String[] {
"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]",
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
});
}
} ///:~

Actually I have the bruceeckel source code in My Document and also the Java Documentation in the same My Document and each time I try to import from the Java documentation the program gets compiled while the import com.bruceeckel refuses to compile.I think may be this has to do with my classpath or path which I did not set right this is the classpath I set please help me to know how to access this
CLASSPATH:C:\MyJavaLib;C:\MyJavaLib\myutils.jar;C:\MyJavaLib\blackboxclasses.jar;
C:\Documents and Settings\User\My Documents\IntValue.java:15: class MutableInteger is public, should be declared in a file named MutableInteger.java
public class MutableInteger {
^
C:\Documents and Settings\User\My Documents\IntValue.java:3: package com.bruceeckel.simpletest does not exist
import com.bruceeckel.simpletest.*;
^
C:\Documents and Settings\User\My Documents\IntValue.java:16: cannot find symbol
symbol : class Test
location: class MutableInteger
private static Test monitor = new Test();
^
C:\Documents and Settings\User\My Documents\IntValue.java:16: cannot find symbol
symbol : class Test
location: class MutableInteger
private static Test monitor = new Test();
^
Note: C:\Documents and Settings\User\My Documents\IntValue.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors

Tool completed with exit code 1
17 years ago
Thanks guys i'm just trying to give myself some time to digest this and may be from this,i could start thinking in the java language.But if anybody have a book/material or links to where i could get to understand this code and programming of a thing from the scratch.It would be surprising that this is the first time i'm laying my hand on anything programming and i know next to nothing but in my intended school when we will be resuming this session we will be having a course that requires a knowledge of Java or C++ as a pre-requisite,so you could see the reason i have to learn by force.
I really appreciate you guys for your contribution,i am ready to learn.
17 years ago
I have tried to input the main argument but i think it just go to reflect that i'm a complete novice.i tried adding the main argument and it just wouldn't compile,this is how the code looks like and it throws up error
/* This class uses API introduced in 1.1. */

import java.util.Locale;

public class FirstClass {
public static void main (string[] args)
{
public String getString() {
return Locale.getDefault().getDisplayName();
}
}
}

this is the error message,please do not get pissed with me,i really need help and if anybody could help me in terms of materials i will really appreciate it
C:\java\java src\FirstClass.java:8: illegal start of expression
public String getString() {
^
C:\java\java src\FirstClass.java:11: ';' expected
}
^
2 errors
17 years ago
Even the BicycleDemo too is not compiling here is the code and below it is the error it brought forward
import java.lang.*;
class BicycleDemo {
public static void main(String[] args) {

// Create two different Bicycle objects
Bicycle bike1 = new Bicycle();
Bicycle bike2 = new Bicycle();

// Invoke methods on those objects
bike1.changeCadence(50);
bike1.speedUp(10);
bike1.changeGear(2);
bike1.printStates();

bike2.changeCadence(50);
bike2.speedUp(10);
bike2.changeGear(2);
bike2.changeCadence(40);
bike2.speedUp(10);
bike2.changeGear(3);
bike2.printStates();
}
}


C:\Documents and Settings\User\My Documents\BicycleDemo.java:6: cannot find symbol
symbol : class Bicycle
location: class BicycleDemo
Bicycle bike1 = new Bicycle();
^
C:\Documents and Settings\User\My Documents\BicycleDemo.java:6: cannot find symbol
symbol : class Bicycle
location: class BicycleDemo
Bicycle bike1 = new Bicycle();
^
C:\Documents and Settings\User\My Documents\BicycleDemo.java:7: cannot find symbol
symbol : class Bicycle
location: class BicycleDemo
Bicycle bike2 = new Bicycle();
^
C:\Documents and Settings\User\My Documents\BicycleDemo.java:7: cannot find symbol
symbol : class Bicycle
location: class BicycleDemo
Bicycle bike2 = new Bicycle();
^
4 errors

Tool completed with exit code 1
17 years ago
Actually I have the bruceeckel source code in My Document and also the Java Documentation in the same My Document and each time I try to import from the Java documentation the program gets compiled while the import com.bruceeckel refuses to compile.I think may be this has to do with my classpath or path which I did not set right this is the classpath I set please help me to know how to access this
CLASSPATH:C:\MyJavaLib;C:\MyJavaLib\myutils.jar;C:\MyJavaLib\blackboxclasses.jar;


//: appendixa:MutableInteger.java
// A changeable wrapper class.
import com.bruceeckel.simpletest.*;
import java.util.*;

class IntValue {
private int n;
public IntValue(int x) { n = x; }
public int getValue() { return n; }
public void setValue(int n) { this.n = n; }
public void increment() { n++; }
public String toString() { return Integer.toString(n); }
}

public class MutableInteger {
private static Test monitor = new Test();
public static void main(String[] args) {
List v = new ArrayList();
for(int i = 0; i < 10; i++)
v.add(new IntValue(i));
System.out.println(v);
for(int i = 0; i < v.size(); i++)
((IntValue)v.get(i)).increment();
System.out.println(v);
monitor.expect(new String[] {
"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]",
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
});
}
} ///:~
17 years ago
thanks Guys i'm beginning to learn this language and i bet by the next 2-3 months,i should have gone beyond this stage.
17 years ago
Everything time i try to compile it wouldn't and i do ot know what is wrong,please somone help me to correct it,compile and run it on my behalf.And finally i need to know where the mistake are.
//: c05:Lunch.java
// Demonstrates class access specifiers. Make a class
// effectively private with private constructors:

class Soup {
private Soup() {}
// (1) Allow creation via static method:
public static Soup makeSoup() {
return new Soup();
}
// (2) Create a static object and return a reference
// upon request.(The "Singleton" pattern):
private static Soup ps1 = new Soup();
public static Soup access() {
return ps1;
}
public void f() {}
}

class Sandwich { // Uses Lunch
void f() { new Lunch(); }
}

// Only one public class allowed per file:
public class Lunch {
void test() {
// Can't do this! Private constructor:
//! Soup priv1 = new Soup();
Soup priv2 = Soup.makeSoup();
Sandwich f1 = new Sandwich();
Soup.access().f();
}
} ///:~

This is the error it throws out
C:\java\java src\Soup.java:25: class Lunch is public, should be declared in a file named Lunch.java
public class Lunch {
^
1 error

Tool completed with exit code 1
17 years ago
I want to know wha i can do or what to add to it to make it run,please help me to make it run.
import java.lang.*;
class Bicycle{
int cadence=0;
int speed=0;
int gear=1;
void changeCadence(int newValue) {
cadence=newValue;
}
void changeGear(int newValue) {
gear=newValue;
}
void speedUp(int increment) {
speed=speed+increment;
}
void applyBrakes(int decrement) {
speed=speed-decrement;
}
void printStates() {
System.out.println("cadence:"+cadence+"speed:"+speed+"gear:"+gear);
}
}
17 years ago
Whenever i try to run this program even though after successful compilation it is throwing back this error
Exception in thread "main" java.lang.NoSuchMethodError: main

And this is he program

/* This class uses API introduced in 1.1. */

import java.util.Locale;

public class FirstClass {
public String getString() {
return Locale.getDefault().getDisplayName();
}
}
17 years ago
Thanks so much for the advice it really works but when i try to run it is giving me
"exception in thread "main" java.lang.NoSuchMethodError: main"
17 years ago
Most times when i try to compile this is what i do get,i am a complete newbie and i will like to know what i am doing that is wrong.Most of the tie the errors are always cannot find symbol.Below is an example:

C:\Documents and Settings\User\My Documents\Bicycle.java:19: cannot find symbol
symbol : method printIn(java.lang.String)
location: class java.io.PrintStream
System.out.printIn("cadence:"+cadence+"speed:"+speed+"gear:"+gear);
^
1 error

Tool completed with exit code 1

This is the program i tried to run

import java.lang.*;
class Bicycle{
int cadence=0;
int speed=0;
int gear=1;
void changeCadence(int newValue) {
cadence=newValue;
}
void changeGear(int newValue) {
gear=newValue;
}
void speedUp(int increment) {
speed=speed+increment;
}
void applyBrakes(int decrement) {
speed=speed-decrement;
}
void printStates() {
System.out.printIn("cadence:"+cadence+"speed:"+speed+"gear:"+gear);
}
}
17 years ago
Thanks Guys,already i'm using textpad is that really advisable or should i better switch on to Jcreator as you advised.I have a lot from supposed expert who have tried to point out that for a beginner textpad is the best.
17 years ago
How to get the IDE to use,i'm a complete newbie and i've tried to download textpad but it couldn't be downloaded.I strongly need help.
17 years ago