Click here to Skip to main content
15,921,646 members
Home / Discussions / Java
   

Java

 
SuggestionRe: help.... Pin
RaviRanjanKr3-Dec-11 10:21
professionalRaviRanjanKr3-Dec-11 10:21 
AnswerRe: help.... Pin
Aniket S Kulkarni28-Nov-11 20:11
Aniket S Kulkarni28-Nov-11 20:11 
GeneralRe: help.... Pin
RaviRanjanKr3-Dec-11 10:28
professionalRaviRanjanKr3-Dec-11 10:28 
GeneralRe: help.... Pin
SilimSayo19-Dec-11 15:44
SilimSayo19-Dec-11 15:44 
AnswerRe: help.... Pin
TorstenH.29-Nov-11 0:00
TorstenH.29-Nov-11 0:00 
GeneralRe: help.... Pin
Richard MacCutchan29-Nov-11 0:47
mveRichard MacCutchan29-Nov-11 0:47 
GeneralRe: help.... Pin
TorstenH.29-Nov-11 19:38
TorstenH.29-Nov-11 19:38 
Questionhow to create constructor for array? Pin
rohaya8815-Nov-11 0:53
rohaya8815-Nov-11 0:53 
hi! This is my class Roster.
C#
public class Roster
{
   int[] shift;
   int length;
   //default constructor
    public Roster()
    {
        length=30;
        shift=new int[length];
     }
     //normal constructor
     public Roster(int[] s)
     {
       shift=s;

      }
      //accessor method
      public int[] getShift()
      {
          return shift;
      }


       public int getLength()
      {
          return shift.length;
       }



      public String display()
      {
          String out="";
          for(int i=0;i<length;i++)
          {
              out+= shift[i] + " ";

           }
         return out;
       }
   }

i'm not sure this coding above is correct or not. Output can't display in text file.hope u all can help me fix this problem

This is main class

public class NurseMain

{ public static void main(String[] arg) throws IOException

{
try
{

FileReader reader = new FileReader("Roster.txt");
BufferedReader in = new BufferedReader(reader);

FileWriter writer1 = new FileWriter("Output.txt");
BufferedWriter bw1 = new BufferedWriter(writer1);
PrintWriter out1 = new PrintWriter(bw1);

FileWriter writer2 = new FileWriter("initialAffinity.txt");
BufferedWriter bw2 = new BufferedWriter(writer2);
PrintWriter out2 = new PrintWriter(bw2);

FileWriter writer3 = new FileWriter("initialClash.txt");
BufferedWriter bw3 = new BufferedWriter(writer3);
PrintWriter out3 = new PrintWriter(bw3);

String input=null;

ArrayList RosterList = new ArrayList();

int length=30;
Roster R = new Roster();
int[] shift=new int[length];

while ((input = in.readLine()) != null)
{
StringTokenizer st = new StringTokenizer(input,",");
for(int i=0;i<shift.length;i++)
{
shift[i]= Integer.parseInt(st.nextToken());

R=new Roster(shift);
}

RosterList.add(R);

}//end while
for(int j=0;j<RosterList.size();j++)
{
R=(Roster)RosterList.get(j);

out1.println(R.display());
}
AnswerRe: how to create constructor for array? Pin
TorstenH.15-Nov-11 1:16
TorstenH.15-Nov-11 1:16 
GeneralRe: how to create constructor for array? Pin
rohaya8815-Nov-11 1:46
rohaya8815-Nov-11 1:46 
GeneralRe: how to create constructor for array? Pin
TorstenH.15-Nov-11 2:01
TorstenH.15-Nov-11 2:01 
GeneralRe: how to create constructor for array? Pin
rohaya8815-Nov-11 2:12
rohaya8815-Nov-11 2:12 
GeneralRe: how to create constructor for array? Pin
TorstenH.15-Nov-11 2:56
TorstenH.15-Nov-11 2:56 
AnswerRe: how to create constructor for array? Pin
mirzabeigi8-Dec-11 7:43
mirzabeigi8-Dec-11 7:43 
SuggestionRe: how to create constructor for array? Pin
RaviRanjanKr1-Jan-12 1:57
professionalRaviRanjanKr1-Jan-12 1:57 
QuestionHow can I disable my Window 7 Desktop in Java Pin
flashery12-Nov-11 15:20
flashery12-Nov-11 15:20 
AnswerRe: How can I disable my Window 7 Desktop in Java Pin
RaviRanjanKr12-Nov-11 20:28
professionalRaviRanjanKr12-Nov-11 20:28 
GeneralRe: How can I disable my Window 7 Desktop in Java Pin
flashery12-Nov-11 23:52
flashery12-Nov-11 23:52 
AnswerRe: How can I disable my Window 7 Desktop in Java Pin
Member 835399113-Nov-11 1:40
Member 835399113-Nov-11 1:40 
AnswerRe: How can I disable my Window 7 Desktop in Java Pin
Nagy Vilmos13-Nov-11 23:46
professionalNagy Vilmos13-Nov-11 23:46 
GeneralRe: How can I disable my Window 7 Desktop in Java Pin
flashery14-Nov-11 1:14
flashery14-Nov-11 1:14 
GeneralRe: How can I disable my Window 7 Desktop in Java Pin
Nagy Vilmos14-Nov-11 1:30
professionalNagy Vilmos14-Nov-11 1:30 
GeneralRe: How can I disable my Window 7 Desktop in Java Pin
flashery14-Nov-11 1:33
flashery14-Nov-11 1:33 
AnswerRe: How can I disable my Window 7 Desktop in Java Pin
jschell14-Nov-11 8:18
jschell14-Nov-11 8:18 
AnswerRe: How can I disable my Window 7 Desktop in Java Pin
TorstenH.14-Nov-11 22:18
TorstenH.14-Nov-11 22:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.