473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

using data

Take Class PrintStream as the starting point, looked this up on sun microsystems
and looking through the available methods to find one that will do what i need to do, the problem then becomes how to use it take "public void print(char c)" for example, have tried lots of ways to no avail typically
Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. class displayIt{
  5.  
  6. static OutputStream      outputStream;
  7.  
  8. public static void main(String[] args)
  9. {
  10.  System.out.println("Hello ");
  11.  
  12.  
  13.  
  14.  
  15. }
  16.  
  17. class PrintStream{
  18.  
  19. PrintStream.print("help");
  20.  
  21. }
  22. }
  23.  
can you please correct my errors or post example if possible so i can see where i am going wrong
Apr 30 '09 #1
3 1326
chaarmann
785 Expert 512MB
You are defining object outputStream and class PrintStream, but you don't use it!
Also how can your computer call method "print" of your class PrintStream if you don't define it anywhere? You should get a compiler error there, don't ignore compiler errors.
Just do the Java Tutorials first, it will tell you how to write classes and methods (the very basics of programming) and how to use them properly.
May 1 '09 #2
Hi just a bit of background I am a mature student (52) I have studied Borland C++ at Manchester Metropolitan University, and some java, recently I have need to communicate between two computers using COM ports something that Borland C++ does not readily do, looking at the options I found that I could use java to achieve this task. However I realized from the off that there was areas of java that I did not understand, I have followed your advise and started the tutorials! Which are easy to follow more over they overlap my knowledge of Borland C++ in as much that I all ready have a good understanding of things like arrays etc

So in conclusion I see that to access a method in another class I do the following
Expand|Select|Wrap|Line Numbers
  1. Bicycle bike1 = new Bicycle();  //make an instance of the class
  2.  
I can then access the printStates(); method in the Bicycle class using

Expand|Select|Wrap|Line Numbers
  1. bike1.printStates();
  2.  
So applying this to my own project
Expand|Select|Wrap|Line Numbers
  1. PrintStream ps = new PrintStream();
  2.  
  3. ps.print(int 22);
  4.  
Which does not work can you please help why? Also you correctly point out that I have define things that I am not using here, they are to be used later they are part of an example that I am trying to modify to meet my needs


The over all idea is to develop a system to help a child with autism using a word selection and reward scheme controlled by an adult using the second PC , mainly because the nature of the condition of having autism often leads to shyness and the computer screen is easier to tolerate than face to face contact

Regards Peter
May 1 '09 #3
JosAH
11,448 Expert 8TB
As you can see from the constructors for the PrintStream class it needs another OutputStream to send its output to; i.e. it 'wraps' the other OutputStream and decorates it with its own methods. We have an article about this design pattern in the 'insights' section of this forum.

kind regards,

Jos
May 1 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
5
by: John Dumais | last post by:
Hello, I have been trying to figure out how to write an array of doubles (in this specific case) to a binary stream without using a loop. What I have been doing is... foreach(double d in...
0
by: khawar | last post by:
here is my code that i am using to send the post to verisign: using System.Drawing; using System.Data; using System.Data.SqlClient; using System.Data.OleDb; using System; using System.Web.UI;...
0
by: zhaoJian | last post by:
Here it is my code ,but it can't update the database.How to do it ? In _UpdateUnit event, I can not get the original value to @Original_UnitID,so I set a hidden column named LabelKey.But It...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
14
by: Steve Teeples | last post by:
I don't understand why I cannot use a property to modify data within a struct. Can someone tell me why I get the error "Cannot modify the return value of "myData.TheData" because it is not a...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.